EmitterBuilder

Struct EmitterBuilder 

Source
pub struct EmitterBuilder<'a> { /* private fields */ }
Expand description

Builder for emitters.

Implementations§

Source§

impl<'a> EmitterBuilder<'a>

Source

pub fn new<W: Write + 'a>(writer: W) -> Result<Self, EmitterError>

Start building an emitter.

Examples found in repository?
examples/canonicalize.rs (line 10)
5fn main() -> Result<(), Box<dyn error::Error>> {
6    // Parser with default configuration.
7    let parser = libyaml::Parser::new(io::stdin())?;
8
9    // Emitter with custom configuration: enable canonical output.
10    let mut emitter = libyaml::EmitterBuilder::new(io::stdout())?
11        .canonical(true)
12        .finish();
13
14    // Parser implements IntoIterator and thus can be used in a for loop.
15    for event in parser {
16        emitter.emit(event?)?;
17    }
18
19    Ok(())
20}
Source

pub fn finish(self) -> Box<Emitter<'a>>

Finish building an emitter.

Examples found in repository?
examples/canonicalize.rs (line 12)
5fn main() -> Result<(), Box<dyn error::Error>> {
6    // Parser with default configuration.
7    let parser = libyaml::Parser::new(io::stdin())?;
8
9    // Emitter with custom configuration: enable canonical output.
10    let mut emitter = libyaml::EmitterBuilder::new(io::stdout())?
11        .canonical(true)
12        .finish();
13
14    // Parser implements IntoIterator and thus can be used in a for loop.
15    for event in parser {
16        emitter.emit(event?)?;
17    }
18
19    Ok(())
20}
Source

pub fn canonical(self, enable: bool) -> Self

Enable or disable canonical output.

Examples found in repository?
examples/canonicalize.rs (line 11)
5fn main() -> Result<(), Box<dyn error::Error>> {
6    // Parser with default configuration.
7    let parser = libyaml::Parser::new(io::stdin())?;
8
9    // Emitter with custom configuration: enable canonical output.
10    let mut emitter = libyaml::EmitterBuilder::new(io::stdout())?
11        .canonical(true)
12        .finish();
13
14    // Parser implements IntoIterator and thus can be used in a for loop.
15    for event in parser {
16        emitter.emit(event?)?;
17    }
18
19    Ok(())
20}
Source

pub fn encoding(self, encoding: Encoding) -> Self

Set encoding.

Source

pub fn indent(self, indent: usize) -> Self

Set indentation increment.

Source

pub fn line_break(self, line_break: LineBreak) -> Self

Set line break encoding.

Source

pub fn line_width(self, width: usize) -> Self

Set preferred line width.

Source

pub fn unicode(self, enable: bool) -> Self

Enable or disable unescaped non-ASCII characters in output.

Auto Trait Implementations§

§

impl<'a> Freeze for EmitterBuilder<'a>

§

impl<'a> !RefUnwindSafe for EmitterBuilder<'a>

§

impl<'a> !Send for EmitterBuilder<'a>

§

impl<'a> !Sync for EmitterBuilder<'a>

§

impl<'a> Unpin for EmitterBuilder<'a>

§

impl<'a> !UnwindSafe for EmitterBuilder<'a>

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.