Struct transmog_async::TransmogWriter
source · pub struct TransmogWriter<W, T, D, F> { /* private fields */ }
Expand description
A wrapper around an asynchronous sink that accepts, serializes, and sends Transmog-encoded values.
To use, provide a writer that implements [AsyncWrite
], and then use [Sink
] to send values.
Note that an TransmogWriter
must be of the type AsyncDestination
in order to be
compatible with an TransmogReader
on the remote end (recall that it requires the
serialized size prefixed to the serialized data). The default is SyncDestination
, but these
can be easily toggled between using TransmogWriter::for_async
.
Implementations§
source§impl<W, T, D, F> TransmogWriter<W, T, D, F>
impl<W, T, D, F> TransmogWriter<W, T, D, F>
sourcepub fn format(&self) -> &F
pub fn format(&self) -> &F
Gets a reference to the underlying format.
It is inadvisable to directly write to the underlying writer.
sourcepub fn get_ref(&self) -> &W
pub fn get_ref(&self) -> &W
Gets a reference to the underlying writer.
It is inadvisable to directly write to the underlying writer.
sourcepub fn get_mut(&mut self) -> &mut W
pub fn get_mut(&mut self) -> &mut W
Gets a mutable reference to the underlying writer.
It is inadvisable to directly write to the underlying writer.
sourcepub fn into_inner(self) -> (W, F)
pub fn into_inner(self) -> (W, F)
Unwraps this TransmogWriter
, returning the underlying writer.
Note that any leftover serialized data that has not yet been sent is lost.
source§impl<W, T, F> TransmogWriter<W, T, SyncDestination, F>
impl<W, T, F> TransmogWriter<W, T, SyncDestination, F>
sourcepub fn new(writer: W, format: F) -> Self
pub fn new(writer: W, format: F) -> Self
Returns a new instance that sends format
-encoded data over writer
.
sourcepub fn default_for(format: F) -> Selfwhere
W: Default,
pub fn default_for(format: F) -> Selfwhere W: Default,
Returns a new instance that sends format
-encoded data over
W::defcfault()
.
source§impl<W, T, F> TransmogWriter<W, T, SyncDestination, F>
impl<W, T, F> TransmogWriter<W, T, SyncDestination, F>
sourcepub fn for_async(self) -> TransmogWriter<W, T, AsyncDestination, F>
pub fn for_async(self) -> TransmogWriter<W, T, AsyncDestination, F>
Make this writer include the serialized data’s size before each serialized value.
This is necessary for compatability with TransmogReader
.
source§impl<W, T, F> TransmogWriter<W, T, AsyncDestination, F>
impl<W, T, F> TransmogWriter<W, T, AsyncDestination, F>
sourcepub fn for_sync(self) -> TransmogWriter<W, T, SyncDestination, F>
pub fn for_sync(self) -> TransmogWriter<W, T, SyncDestination, F>
Make this writer only send Transmog-encoded values.
This is necessary for compatability with stock Transmog receivers.
Trait Implementations§
source§impl<W, T, D, F> Sink<T> for TransmogWriter<W, T, D, F>where
F: Format<'static, T>,
W: AsyncWrite + Unpin,
Self: TransmogWriterFor<T, F>,
impl<W, T, D, F> Sink<T> for TransmogWriter<W, T, D, F>where F: Format<'static, T>, W: AsyncWrite + Unpin, Self: TransmogWriterFor<T, F>,
§type Error = <F as Format<'static, T>>::Error
type Error = <F as Format<'static, T>>::Error
source§fn poll_ready(
self: Pin<&mut Self>,
_: &mut Context<'_>
) -> Poll<Result<(), Self::Error>>
fn poll_ready( self: Pin<&mut Self>, _: &mut Context<'_> ) -> Poll<Result<(), Self::Error>>
Sink
to receive a value. Read moresource§fn start_send(self: Pin<&mut Self>, item: T) -> Result<(), Self::Error>
fn start_send(self: Pin<&mut Self>, item: T) -> Result<(), Self::Error>
poll_ready
which returned Poll::Ready(Ok(()))
. Read more