Struct ByteStream

Source
pub struct ByteStream(/* private fields */);
Expand description

Untyped byte stream used for both success and error responses.

Implementations§

Source§

impl ByteStream

Source

pub fn new( inner: Pin<Box<dyn Stream<Item = Result<Bytes, Error>> + Sync + Send>>, ) -> ByteStream

Creates a new ByteStream

Useful for generating test fixtures.

Source

pub fn into_inner( self, ) -> Pin<Box<dyn Stream<Item = Result<Bytes, Error>> + Sync + Send>>

Consumes the ByteStream and return its inner Stream.

Methods from Deref<Target = Pin<Box<dyn Stream<Item = Result<Bytes, Error>> + Sync + Send>>>§

1.33.0 · Source

pub fn as_ref(&self) -> Pin<&<Ptr as Deref>::Target>

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 · Source

pub fn as_mut(&mut self) -> Pin<&mut <Ptr as Deref>::Target>

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 · Source

pub fn as_deref_mut( self: Pin<&mut Pin<Ptr>>, ) -> Pin<&mut <Ptr as Deref>::Target>

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 · Source

pub fn set(&mut self, value: <Ptr as Deref>::Target)
where <Ptr as Deref>::Target: Sized,

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); // 10

Trait Implementations§

Source§

impl Deref for ByteStream

Source§

type Target = Pin<Box<dyn Stream<Item = Result<Bytes, Error>> + Sync + Send>>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<ByteStream as Deref>::Target

Dereferences the value.
Source§

impl DerefMut for ByteStream

Source§

fn deref_mut(&mut self) -> &mut <ByteStream as Deref>::Target

Mutably dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T