hcl::ser

Struct Serializer

Source
pub struct Serializer<'a, W> { /* private fields */ }
Expand description

A structure for serializing Rust values into HCL.

Implementations§

Source§

impl<'a, W> Serializer<'a, W>
where W: Write,

Source

pub fn new(writer: W) -> Serializer<'a, W>

Creates a new Serializer which serializes to the provides writer using the default formatter.

Source

pub fn with_formatter(formatter: Formatter<'a, W>) -> Serializer<'a, W>

Creates a new Serializer which uses the provides formatter to format the serialized HCL.

Source

pub fn into_inner(self) -> W

Consumes self and returns the wrapped writer.

Source

pub fn serialize<T>(&mut self, value: &T) -> Result<()>
where T: ?Sized + Serialize,

Serialize the given value as HCL via the serializer’s Formatter to the underlying writer.

§Errors

Serialization fails if the type cannot be represented as HCL.

Source§

impl<'a, W> Serializer<'a, W>
where W: Write + AsMut<Vec<u8>>,

Source

pub fn serialize_string<T>(&mut self, value: &T) -> Result<String>
where T: ?Sized + Serialize,

Serialize the given value as HCL and returns the result as a String.

§Errors

Serialization fails if the type cannot be represented as HCL.

Source

pub fn serialize_vec<T>(&mut self, value: &T) -> Result<Vec<u8>>
where T: ?Sized + Serialize,

Serialize the given value as HCL and returns the result as a Vec<u8>.

§Errors

Serialization fails if the type cannot be represented as HCL.

Auto Trait Implementations§

§

impl<'a, W> Freeze for Serializer<'a, W>
where W: Freeze,

§

impl<'a, W> RefUnwindSafe for Serializer<'a, W>
where W: RefUnwindSafe,

§

impl<'a, W> Send for Serializer<'a, W>
where W: Send,

§

impl<'a, W> Sync for Serializer<'a, W>
where W: Sync,

§

impl<'a, W> Unpin for Serializer<'a, W>
where W: Unpin,

§

impl<'a, W> UnwindSafe for Serializer<'a, 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.