[][src]Struct tokio_serde_json::ReadJson

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

Adapts a stream of JSON encoded buffers to a stream of values by deserializing them.

ReadJson implements Sink by polling the inner buffer stream and deserializing the buffer as JSON. It expects that each yielded buffer represents a single JSON value and does not contain any extra trailing bytes.

If a ReadJson is used concurrently from two or more threads, it is guaranteed that only one object will be read at a time. In other words, once an object begins being read, that object will continue being read until it finishes or errors, and another object will only be read once the first object completes.

Methods

impl<T, U> ReadJson<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 stream wrapped by ReadJson.

Note that care should be taken to not tamper with the underlying stream of data coming in as it may corrupt the stream of frames otherwise being worked with.

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

Returns a mutable reference to the underlying stream wrapped by ReadJson.

Note that care should be taken to not tamper with the underlying stream of data coming in as it may corrupt the stream of frames otherwise being worked with.

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

Consumes the ReadJson, returning its underlying stream.

Note that care should be taken to not tamper with the underlying stream of data coming in as it may corrupt the stream of frames otherwise being worked with.

Trait Implementations

impl<'_pin, T, U> Unpin for ReadJson<T, U> where
    __UnpinStructReadJson<'_pin, T, U>: Unpin
[src]

impl<T, U, SinkItem> Sink<SinkItem> for ReadJson<T, U> where
    T: Sink<SinkItem>, 
[src]

type Error = T::Error

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

impl<T, U> Stream for ReadJson<T, U> where
    T: TryStream<Ok = BytesMut>,
    T::Error: From<Error>,
    U: Deserialize<'a>, 
[src]

type Item = Result<U, T::Error>

Values yielded by the stream.

Auto Trait Implementations

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

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

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

impl<T, U> RefUnwindSafe for ReadJson<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]