Struct zerotier_central_api::ByteStream
source · pub struct ByteStream(_);
Expand description
Untyped byte stream used for both success and error responses.
Implementations§
source§impl ByteStream
impl ByteStream
sourcepub fn new(
inner: Pin<Box<dyn Stream<Item = Result<Bytes, Error>> + Sync + Send + 'static, Global>>
) -> ByteStream
pub fn new( inner: Pin<Box<dyn Stream<Item = Result<Bytes, Error>> + Sync + Send + 'static, Global>> ) -> ByteStream
Creates a new ByteStream
Useful for generating test fixtures.
sourcepub fn into_inner(
self
) -> Pin<Box<dyn Stream<Item = Result<Bytes, Error>> + Sync + Send + 'static, Global>>
pub fn into_inner( self ) -> Pin<Box<dyn Stream<Item = Result<Bytes, Error>> + Sync + Send + 'static, Global>>
Consumes the ByteStream
and return its inner [Stream
].
Methods from Deref<Target = Pin<Box<dyn Stream<Item = Result<Bytes, Error>> + Sync + Send + 'static, Global>>>§
1.33.0 · sourcepub fn as_ref(&self) -> Pin<&<P as Deref>::Target>
pub fn as_ref(&self) -> Pin<&<P as Deref>::Target>
Gets a pinned shared reference from this pinned pointer.
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 <P as Deref>::Target>
pub fn as_mut(&mut self) -> Pin<&mut <P as Deref>::Target>
Gets a pinned mutable reference from this pinned pointer.
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 pinned type.
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.33.0 · sourcepub fn set(&mut self, value: <P as Deref>::Target)where
<P as Deref>::Target: Sized,
pub fn set(&mut self, value: <P as Deref>::Target)where <P as Deref>::Target: Sized,
Assigns a new value to the memory behind the pinned reference.
This overwrites pinned data, but that is okay: its destructor gets run before being overwritten, so no pinning guarantee is violated.
Example
use std::pin::Pin;
let mut val: u8 = 5;
let mut pinned: Pin<&mut u8> = Pin::new(&mut val);
println!("{}", pinned); // 5
pinned.as_mut().set(10);
println!("{}", pinned); // 10