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>

source

pub fn format(&self) -> &F

Gets a reference to the underlying format.

It is inadvisable to directly write to the underlying writer.

source

pub fn get_ref(&self) -> &W

Gets a reference to the underlying writer.

It is inadvisable to directly write to the underlying writer.

source

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.

source

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>

source

pub fn new(writer: W, format: F) -> Self

Returns a new instance that sends format-encoded data over writer.

source

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>

source

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>

source

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: Debug, T: Debug, D: Debug, F: Debug> Debug for TransmogWriter<W, T, D, F>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
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>,

§

type Error = <F as Format<'static, T>>::Error

The type of value produced by the sink when an error occurs.
source§

fn poll_ready( self: Pin<&mut Self>, _: &mut Context<'_> ) -> Poll<Result<(), Self::Error>>

Attempts to prepare the Sink to receive a value. Read more
source§

fn start_send(self: Pin<&mut Self>, item: T) -> Result<(), Self::Error>

Begin the process of sending a value to the sink. Each call to this function must be preceded by a successful call to poll_ready which returned Poll::Ready(Ok(())). Read more
source§

fn poll_flush( self: Pin<&mut Self>, cx: &mut Context<'_> ) -> Poll<Result<(), Self::Error>>

Flush any remaining output from this sink. Read more
source§

fn poll_close( self: Pin<&mut Self>, cx: &mut Context<'_> ) -> Poll<Result<(), Self::Error>>

Flush any remaining output and close this sink, if necessary. Read more
source§

impl<W, T, D, F> Unpin for TransmogWriter<W, T, D, F>where W: Unpin,

Auto Trait Implementations§

§

impl<W, T, D, F> RefUnwindSafe for TransmogWriter<W, T, D, F>where D: RefUnwindSafe, F: RefUnwindSafe, T: RefUnwindSafe, W: RefUnwindSafe,

§

impl<W, T, D, F> Send for TransmogWriter<W, T, D, F>where D: Send, F: Send, T: Send, W: Send,

§

impl<W, T, D, F> Sync for TransmogWriter<W, T, D, F>where D: Sync, F: Sync, T: Sync, W: Sync,

§

impl<W, T, D, F> UnwindSafe for TransmogWriter<W, T, D, F>where D: UnwindSafe, F: UnwindSafe, T: UnwindSafe, W: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.