Struct dts_core::ser::Serializer
source · [−]pub struct Serializer<W> { /* private fields */ }Expand description
A Serializer can serialize a Value into an encoded byte stream.
Implementations
sourceimpl<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> 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more