pub struct Serializer<W> { /* private fields */ }Expand description
A Serializer can serialize a Value into an encoded byte stream.
Implementations§
Source§impl<W> Serializer<W>where
W: Write,
impl<W> Serializer<W>where
W: Write,
Sourcepub fn with_options(writer: W, opts: SerializeOptions) -> Self
pub fn with_options(writer: W, opts: SerializeOptions) -> Self
Creates a new Serializer for writer with options.
Sourcepub fn serialize(&mut self, encoding: Encoding, value: Value) -> Result<()>
pub fn serialize(&mut self, encoding: Encoding, value: Value) -> Result<()>
Serializes the given Value and writes the encoded data to the writer.
§Example
use dts_core::{ser::SerializerBuilder, Encoding};
use serde_json::json;
let mut buf = Vec::new();
let mut ser = SerializerBuilder::new().compact(true).build(&mut buf);
ser.serialize(Encoding::Json, json!(["foo"]))?;
assert_eq!(&buf, r#"["foo"]"#.as_bytes());Auto Trait Implementations§
impl<W> Freeze for Serializer<W>where
W: Freeze,
impl<W> RefUnwindSafe for Serializer<W>where
W: RefUnwindSafe,
impl<W> Send for Serializer<W>where
W: Send,
impl<W> Sync for Serializer<W>where
W: Sync,
impl<W> Unpin for Serializer<W>where
W: Unpin,
impl<W> UnwindSafe for Serializer<W>where
W: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more