Struct Encoder

Source
pub struct Encoder<W> { /* private fields */ }
Expand description

JSON encoder over any Write-type.

Implementations§

Source§

impl<W: Write> Encoder<W>

Source

pub fn new(w: W) -> Encoder<W>

Source

pub fn into_writer(self) -> W

Source

pub fn writer_mut(&mut self) -> &mut W

Source

pub fn to_json<T: ToJson>(&mut self, t: T) -> EncodeResult<()>

Source

pub fn encode(&mut self, j: &Json) -> EncodeResult<()>

Source

pub fn u8(&mut self, x: u8) -> EncodeResult<()>

Source

pub fn u16(&mut self, x: u16) -> EncodeResult<()>

Source

pub fn u32(&mut self, x: u32) -> EncodeResult<()>

Source

pub fn u64(&mut self, x: u64) -> EncodeResult<()>

Source

pub fn usize(&mut self, x: usize) -> EncodeResult<()>

Source

pub fn i8(&mut self, x: i8) -> EncodeResult<()>

Source

pub fn i16(&mut self, x: i16) -> EncodeResult<()>

Source

pub fn i32(&mut self, x: i32) -> EncodeResult<()>

Source

pub fn i64(&mut self, x: i64) -> EncodeResult<()>

Source

pub fn isize(&mut self, x: isize) -> EncodeResult<()>

Source

pub fn i128(&mut self, x: i128) -> EncodeResult<()>

Source

pub fn u128(&mut self, x: u128) -> EncodeResult<()>

Source

pub fn bool(&mut self, x: bool) -> EncodeResult<()>

Source

pub fn null(&mut self) -> EncodeResult<()>

Source

pub fn optional<T: ToJson>(&mut self, val: Option<T>) -> EncodeResult<()>

Source

pub fn string<S: Borrow<str>>(&mut self, s: S) -> EncodeResult<()>

Source

pub fn key<S: Borrow<str>>(&mut self, key: S) -> EncodeResult<()>

Source

pub fn array(&mut self) -> EncodeResult<()>

Begin encoding a new JSON array.

Must be paired with a call to Encoder::end().

Source

pub fn object(&mut self) -> EncodeResult<()>

Begin encoding a new JSON object.

Must be paired with a call to Encoder::end().

Source

pub fn end(&mut self) -> EncodeResult<()>

End a JSON array or object.

Auto Trait Implementations§

§

impl<W> Freeze for Encoder<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for Encoder<W>
where W: RefUnwindSafe,

§

impl<W> Send for Encoder<W>
where W: Send,

§

impl<W> Sync for Encoder<W>
where W: Sync,

§

impl<W> Unpin for Encoder<W>
where W: Unpin,

§

impl<W> UnwindSafe for Encoder<W>
where W: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Source§

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.