#[non_exhaustive]pub enum Sink {
Null,
Vector(Vec<u8>),
File(File),
TcpStream(TcpStream),
Other(Box<dyn AnySink + Send + UnwindSafe>),
}Expand description
A type-abstract data sink
Rationale
The idea behind this type is to provide some dynamic polymorphism, but with some “fast-paths” for common types to avoid the overhead of boxing and vtable-lookup (while the latter is probable negligible, the former may be significant overhead if all you want is to write to some preallocated memory).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Null
A writer which will move data into the void
Vector(Vec<u8>)
A vector sink
File(File)
A file
TcpStream(TcpStream)
A TCP stream
Other(Box<dyn AnySink + Send + UnwindSafe>)
A catch-all/opaque variant for all types that cannot be covered by the enum’s specific variants
Implementations§
source§impl Sink
impl Sink
sourcepub fn from_other<T>(typed: T) -> Self
pub fn from_other<T>(typed: T) -> Self
Creates a new catch-all/opaque variant from a typed object by moving it to the heap
Trait Implementations§
source§impl Write for Sink
impl Write for Sink
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this writer, returning how many bytes were written. Read more
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
write_all_vectored)Attempts to write multiple buffers into this writer. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for Sink
impl Send for Sink
impl !Sync for Sink
impl Unpin for Sink
impl UnwindSafe for Sink
Blanket Implementations§
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
Mutably borrows from an owned value. Read more