[][src]Struct tokio_serde_json::WriteJson

pub struct WriteJson<T, U> { /* fields omitted */ }

Adapts a buffer sink to a value sink by serializing the values as JSON.

WriteJson implements Sink by serializing the submitted values to a buffer. The buffer is then sent to the inner stream, which is responsible for handling framing on the wire.

If a WriteJson is used concurrently from two or more threads, it is guaranteed that the bytes of different objects written will not be interleaved. In other words, if two calls to WriteJson::send overlap, then the bytes of one object will be written entirely before the bytes of the other.

Methods

impl<T, U> WriteJson<T, U>[src]

pub fn new(inner: T) -> Self[src]

Creates a new ReadJson with the given buffer stream.

pub fn get_ref(&self) -> &T[src]

Returns a reference to the underlying sink wrapped by WriteJson.

Note that care should be taken to not tamper with the underlying sink as it may corrupt the sequence of frames otherwise being worked with.

pub fn get_mut(&mut self) -> &mut T[src]

Returns a mutable reference to the underlying sink wrapped by WriteJson.

Note that care should be taken to not tamper with the underlying sink as it may corrupt the sequence of frames otherwise being worked with.

pub fn into_inner(self) -> T[src]

Consumes the WriteJson, returning its underlying sink.

Note that care should be taken to not tamper with the underlying sink as it may corrupt the sequence of frames otherwise being worked with.

Trait Implementations

impl<'_pin, T, U> Unpin for WriteJson<T, U> where
    __UnpinStructWriteJson<'_pin, T, U>: Unpin
[src]

impl<T, U> Sink<U> for WriteJson<T, U> where
    T: Sink<Bytes>,
    T::Error: From<Error>,
    U: Serialize
[src]

type Error = T::Error

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

impl<T, U> Stream for WriteJson<T, U> where
    T: Stream
[src]

type Item = T::Item

Values yielded by the stream.

Auto Trait Implementations

impl<T, U> Send for WriteJson<T, U> where
    T: Send,
    U: Send

impl<T, U> Sync for WriteJson<T, U> where
    T: Sync,
    U: Sync

impl<T, U> UnwindSafe for WriteJson<T, U> where
    T: UnwindSafe,
    U: UnwindSafe

impl<T, U> RefUnwindSafe for WriteJson<T, U> where
    T: RefUnwindSafe,
    U: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> StreamExt for T where
    T: Stream + ?Sized
[src]

impl<S, T, E> TryStream for S where
    S: Stream<Item = Result<T, E>> + ?Sized
[src]

type Ok = T

The type of successful values yielded by this future

type Error = E

The type of failures yielded by this future

impl<S> TryStreamExt for S where
    S: TryStream + ?Sized
[src]

impl<T, Item> SinkExt<Item> for T where
    T: Sink<Item> + ?Sized
[src]