Struct BoxedStream
pub struct BoxedStream<T, E> {
pub(crate) stream: Pin<Box<dyn Stream<Item = Result<T, E>> + Send>>,
}Expand description
A boxed stream type that can be used with the websocket protocol.
You can easily convert any static type that implement [futures::Stream] into a BoxedStream
with the From trait.
ยงExample
use futures::StreamExt;
use server_fn::{BoxedStream, ServerFnError};
let stream: BoxedStream<_, ServerFnError> =
futures::stream::iter(0..10).map(Result::Ok).into();Fieldsยง
ยงstream: Pin<Box<dyn Stream<Item = Result<T, E>> + Send>>Methods from Deref<Target = Pin<Box<dyn Stream<Item = Result<T, E>> + Send>>>ยง
1.33.0 ยท Sourcepub fn as_ref(&self) -> Pin<&<Ptr as Deref>::Target>where
Ptr: Deref,
pub fn as_ref(&self) -> Pin<&<Ptr as Deref>::Target>where
Ptr: Deref,
Gets a shared reference to the pinned value this Pin points to.
This is a generic method to go from &Pin<Pointer<T>> to Pin<&T>.
It is safe because, as part of the contract of Pin::new_unchecked,
the pointee cannot move after Pin<Pointer<T>> got created.
โMaliciousโ implementations of Pointer::Deref are likewise
ruled out by the contract of Pin::new_unchecked.
1.33.0 ยท Sourcepub fn as_mut(&mut self) -> Pin<&mut <Ptr as Deref>::Target>where
Ptr: DerefMut,
pub fn as_mut(&mut self) -> Pin<&mut <Ptr as Deref>::Target>where
Ptr: DerefMut,
Gets a mutable reference to the pinned value this Pin<Ptr> points to.
This is a generic method to go from &mut Pin<Pointer<T>> to Pin<&mut T>.
It is safe because, as part of the contract of Pin::new_unchecked,
the pointee cannot move after Pin<Pointer<T>> got created.
โMaliciousโ implementations of Pointer::DerefMut are likewise
ruled out by the contract of Pin::new_unchecked.
This method is useful when doing multiple calls to functions that consume the pinning pointer.
ยงExample
use std::pin::Pin;
impl Type {
fn method(self: Pin<&mut Self>) {
// do something
}
fn call_method_twice(mut self: Pin<&mut Self>) {
// `method` consumes `self`, so reborrow the `Pin<&mut Self>` via `as_mut`.
self.as_mut().method();
self.as_mut().method();
}
}1.84.0 ยท Sourcepub fn as_deref_mut(
self: Pin<&mut Pin<Ptr>>,
) -> Pin<&mut <Ptr as Deref>::Target>where
Ptr: DerefMut,
pub fn as_deref_mut(
self: Pin<&mut Pin<Ptr>>,
) -> Pin<&mut <Ptr as Deref>::Target>where
Ptr: DerefMut,
Gets Pin<&mut T> to the underlying pinned value from this nested Pin-pointer.
This is a generic method to go from Pin<&mut Pin<Pointer<T>>> to Pin<&mut T>. It is
safe because the existence of a Pin<Pointer<T>> ensures that the pointee, T, cannot
move in the future, and this method does not enable the pointee to move. โMaliciousโ
implementations of Ptr::DerefMut are likewise ruled out by the contract of
Pin::new_unchecked.
1.33.0 ยท Sourcepub fn set(&mut self, value: <Ptr as Deref>::Target)
pub fn set(&mut self, value: <Ptr as Deref>::Target)
Assigns a new value to the memory location pointed to by the Pin<Ptr>.
This overwrites pinned data, but that is okay: the original pinned valueโs destructor gets
run before being overwritten and the new value is also a valid value of the same type, so
no pinning invariant is violated. See the pin module documentation
for more information on how this upholds the pinning invariants.
ยงExample
use std::pin::Pin;
let mut val: u8 = 5;
let mut pinned: Pin<&mut u8> = Pin::new(&mut val);
println!("{}", pinned); // 5
pinned.set(10);
println!("{}", pinned); // 10Trait Implementationsยง
ยงimpl<T, E> Debug for BoxedStream<T, E>
impl<T, E> Debug for BoxedStream<T, E>
ยงimpl<T, E> Deref for BoxedStream<T, E>
impl<T, E> Deref for BoxedStream<T, E>
ยงimpl<T, E> DerefMut for BoxedStream<T, E>
impl<T, E> DerefMut for BoxedStream<T, E>
ยงfn deref_mut(&mut self) -> &mut <BoxedStream<T, E> as Deref>::Target
fn deref_mut(&mut self) -> &mut <BoxedStream<T, E> as Deref>::Target
ยงimpl<T, E, S> From<S> for BoxedStream<T, E>
impl<T, E, S> From<S> for BoxedStream<T, E>
ยงfn from(stream: S) -> BoxedStream<T, E>
fn from(stream: S) -> BoxedStream<T, E>
ยงimpl<Input, InputItem, OutputItem, InputEncoding, OutputEncoding, Client, Server, Error, InputStreamError, OutputStreamError> Protocol<Input, BoxedStream<OutputItem, OutputStreamError>, Client, Server, Error, InputStreamError, OutputStreamError> for Websocket<InputEncoding, OutputEncoding>where
Input: Deref<Target = BoxedStream<InputItem, InputStreamError>> + Into<BoxedStream<InputItem, InputStreamError>> + From<BoxedStream<InputItem, InputStreamError>>,
InputEncoding: Encodes<InputItem> + Decodes<InputItem>,
OutputEncoding: Encodes<OutputItem> + Decodes<OutputItem>,
InputStreamError: FromServerFnError + Send,
OutputStreamError: FromServerFnError + Send,
Error: FromServerFnError + Send,
Server: Server<Error, InputStreamError, OutputStreamError>,
Client: Client<Error, InputStreamError, OutputStreamError>,
OutputItem: Send + 'static,
InputItem: Send + 'static,
impl<Input, InputItem, OutputItem, InputEncoding, OutputEncoding, Client, Server, Error, InputStreamError, OutputStreamError> Protocol<Input, BoxedStream<OutputItem, OutputStreamError>, Client, Server, Error, InputStreamError, OutputStreamError> for Websocket<InputEncoding, OutputEncoding>where
Input: Deref<Target = BoxedStream<InputItem, InputStreamError>> + Into<BoxedStream<InputItem, InputStreamError>> + From<BoxedStream<InputItem, InputStreamError>>,
InputEncoding: Encodes<InputItem> + Decodes<InputItem>,
OutputEncoding: Encodes<OutputItem> + Decodes<OutputItem>,
InputStreamError: FromServerFnError + Send,
OutputStreamError: FromServerFnError + Send,
Error: FromServerFnError + Send,
Server: Server<Error, InputStreamError, OutputStreamError>,
Client: Client<Error, InputStreamError, OutputStreamError>,
OutputItem: Send + 'static,
InputItem: Send + 'static,
ยงasync fn run_server<F, Fut>(
request: <Server as Server<Error, InputStreamError, OutputStreamError>>::Request,
server_fn: F,
) -> Result<<Server as Server<Error, InputStreamError, OutputStreamError>>::Response, Error>
async fn run_server<F, Fut>( request: <Server as Server<Error, InputStreamError, OutputStreamError>>::Request, server_fn: F, ) -> Result<<Server as Server<Error, InputStreamError, OutputStreamError>>::Response, Error>
ยงfn run_client(
path: &str,
input: Input,
) -> impl Future<Output = Result<BoxedStream<OutputItem, OutputStreamError>, Error>> + Send
fn run_client( path: &str, input: Input, ) -> impl Future<Output = Result<BoxedStream<OutputItem, OutputStreamError>, Error>> + Send
Auto Trait Implementationsยง
impl<T, E> Freeze for BoxedStream<T, E>
impl<T, E> !RefUnwindSafe for BoxedStream<T, E>
impl<T, E> Send for BoxedStream<T, E>
impl<T, E> !Sync for BoxedStream<T, E>
impl<T, E> Unpin for BoxedStream<T, E>
impl<T, E> !UnwindSafe for BoxedStream<T, E>
Blanket Implementationsยง
Sourceยงimpl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Sourceยงfn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Sourceยงfn adapt_into(self) -> D
fn adapt_into(self) -> D
Sourceยงimpl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Sourceยงfn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Sourceยงimpl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Sourceยงfn arrays_into(self) -> C
fn arrays_into(self) -> C
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Sourceยงimpl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Sourceยงtype Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Sourceยงfn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Sourceยงimpl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Sourceยงfn components_from(colors: C) -> T
fn components_from(colors: C) -> T
ยงimpl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
ยงfn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.ยงfn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.ยงfn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Anyโs vtable from &Traitโs.ยงfn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Anyโs vtable from &mut Traitโs.ยงimpl<T> DowncastSend for T
impl<T> DowncastSend for T
Sourceยงimpl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Sourceยงfn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Sourceยงimpl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Sourceยงfn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.ยงimpl<T> Instrument for T
impl<T> Instrument for T
ยงfn instrument(self, span: Span) -> Instrumented<Self> โ
fn instrument(self, span: Span) -> Instrumented<Self> โ
Sourceยงimpl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Sourceยงfn into_angle(self) -> U
fn into_angle(self) -> U
T.Sourceยงimpl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Sourceยงtype Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Sourceยงfn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Sourceยงimpl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Sourceยงfn into_color(self) -> U
fn into_color(self) -> U
Sourceยงimpl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Sourceยงfn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self> โ
fn into_either(self, into_left: bool) -> Either<Self, Self> โ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreยงimpl<T, I> IntoReactiveValue<T, __IntoReactiveValueMarkerBaseCase> for Iwhere
I: Into<T>,
impl<T, I> IntoReactiveValue<T, __IntoReactiveValueMarkerBaseCase> for Iwhere
I: Into<T>,
ยงfn into_reactive_value(self) -> T
fn into_reactive_value(self) -> T
self into a T.Sourceยงimpl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Sourceยงfn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.ยงimpl<T> Pointable for T
impl<T> Pointable for T
ยงimpl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
ยงimpl<T> SerializableKey for T
impl<T> SerializableKey for T
ยงimpl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
ยงfn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
ยงfn into_taken(self) -> T
fn into_taken(self) -> T
Sourceยงimpl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Sourceยงtype Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Sourceยงfn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Sourceยงimpl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Sourceยงfn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more