Struct simpleml::SMLWriter

source ·
pub struct SMLWriter<StrAsRef>
where StrAsRef: AsRef<str> + From<&'static str> + ToString,
{ /* private fields */ }

Implementations§

source§

impl<StrAsRef> SMLWriter<StrAsRef>
where StrAsRef: AsRef<str> + From<&'static str> + ToString,

source

pub fn new(values: TreeNode<SMLElement<StrAsRef>>) -> Self

source

pub fn indent_with(self, str: &str) -> Option<Self>

Sets the indentation string to be used in the output. If the passed in str contains any non-whitespace characters, this call will fail and return None.

source

pub fn with_end_keyword(self, str: Option<&str>) -> Self

Sets the end keyword to be used in the output. If the passed in string is the empty string “”, ‘-’ will be used instead.

source

pub fn align_columns(self, alignment: ColumnAlignment) -> Self

Sets the column alignment of the attributes’ generated WSV. The element alignment will be unaffected, but all attributes and their values will be aligned this way.

source

pub fn to_string(self) -> Result<String, SMLWriterError>

Writes the values in this SMLWriter out to a String. This operation can fail if any of the values would result in an SML attribute or element where the name is the same as the “End” keyword. If that happens, you as the caller will receive an Err() variant of Result.

Auto Trait Implementations§

§

impl<StrAsRef> Freeze for SMLWriter<StrAsRef>
where StrAsRef: Freeze,

§

impl<StrAsRef> RefUnwindSafe for SMLWriter<StrAsRef>
where StrAsRef: RefUnwindSafe,

§

impl<StrAsRef> Send for SMLWriter<StrAsRef>
where StrAsRef: Send,

§

impl<StrAsRef> Sync for SMLWriter<StrAsRef>
where StrAsRef: Sync,

§

impl<StrAsRef> Unpin for SMLWriter<StrAsRef>
where StrAsRef: Unpin,

§

impl<StrAsRef> UnwindSafe for SMLWriter<StrAsRef>
where StrAsRef: 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>,

§

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>,

§

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.