pub struct Serializer { /* private fields */ }Expand description
Serializes values into property lists.
A property list holds a single value.
use deser_plist::Serializer;
let mut serializer = Serializer::new();
serializer.serialize(&true).unwrap();
assert!(serializer.output().ends_with(b"<plist version=\"1.0\">\n<true/>\n</plist>\n"));The serializer is also the stream serializer of property lists (see
StreamSerializer). XML and OpenStep
property lists can be written in parts, binary property lists are
written once the value is complete as the object table needs all
objects. To write to a Write use
SerializerConfig::writer.
Implementations§
Source§impl Serializer
impl Serializer
Sourcepub fn new() -> Serializer
pub fn new() -> Serializer
Creates a serializer.
Sourcepub fn with_config(config: SerializerConfig) -> Serializer
pub fn with_config(config: SerializerConfig) -> Serializer
Creates a serializer with the given configuration.
Sourcepub fn config(&self) -> &SerializerConfig
pub fn config(&self) -> &SerializerConfig
Returns the configuration.
Sourcepub fn serialize<T: Serialize + ?Sized>(
&mut self,
value: &T,
) -> Result<(), Error>
pub fn serialize<T: Serialize + ?Sized>( &mut self, value: &T, ) -> Result<(), Error>
Serializes a value.
A property list holds a single value, serializing a second value fails.
Trait Implementations§
Source§impl Clone for Serializer
impl Clone for Serializer
Source§fn clone(&self) -> Serializer
fn clone(&self) -> Serializer
Clones the serializer.
The clone of a serializer that writes a value in parts cannot write
more values (see
StreamSerializer::in_progress).
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Serializer
impl Debug for Serializer
Source§impl Default for Serializer
impl Default for Serializer
Source§impl Serializer for Serializer
impl Serializer for Serializer
Source§fn drive(&mut self, driver: &mut SerializeDriver<'_>) -> Result<(), Error>
fn drive(&mut self, driver: &mut SerializeDriver<'_>) -> Result<(), Error>
Receives the events of a value from the driver and writes them into
the output.
Source§fn serialize_with<T, F>(&mut self, value: &T, setup: F) -> Result<(), Error>
fn serialize_with<T, F>(&mut self, value: &T, setup: F) -> Result<(), Error>
Serializes a value with a configured driver. Read more
Source§fn serialize_ref(&mut self, value: SerializeRef<'_>) -> Result<(), Error>
fn serialize_ref(&mut self, value: SerializeRef<'_>) -> Result<(), Error>
Serializes the value of a reference. Read more
Source§impl StreamSerializer for Serializer
impl StreamSerializer for Serializer
Source§fn supports_partial(&self) -> bool
fn supports_partial(&self) -> bool
XML and OpenStep property lists are written in parts.
Source§fn output(&self) -> &[u8] ⓘ
fn output(&self) -> &[u8] ⓘ
Returns the bytes serialized so far which were not cleared yet. Read more
Source§fn clear_output(&mut self)
fn clear_output(&mut self)
Discards the bytes returned by
output, for
instance because they were written.Source§fn drive_partial(
&mut self,
driver: &mut SerializeDriver<'_>,
limit: usize,
) -> Result<bool, Error>
fn drive_partial( &mut self, driver: &mut SerializeDriver<'_>, limit: usize, ) -> Result<bool, Error>
Serializes a value, or a part of it, and appends its bytes to the
output. Read more
Source§fn in_progress(&self) -> bool
fn in_progress(&self) -> bool
Returns
true if a value is partially serialized. Read moreAuto Trait Implementations§
impl Freeze for Serializer
impl RefUnwindSafe for Serializer
impl Send for Serializer
impl Sync for Serializer
impl Unpin for Serializer
impl UnsafeUnpin for Serializer
impl UnwindSafe for Serializer
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