Struct norad::WriteOptions

source ·
pub struct WriteOptions { /* private fields */ }
Expand description

Options that can be set when writing the UFO to disk.

You construct WriteOptions using builder semantics:

let single_tab = WriteOptions::default();

let two_tabs = WriteOptions::default()
    .whitespace("\t\t");

let spaces = WriteOptions::default()
    .whitespace("  ");

let spaces_and_singlequotes = WriteOptions::default()
    .whitespace("  ")
    .quote_char(QuoteChar::Single);

Implementations§

source§

impl WriteOptions

source

pub const SPACE: u8 = 32u8

The ASCII value of the space character (0x20)

source

pub const TAB: u8 = 9u8

The ASCII value of the tab character (0x09)

source

pub fn new() -> Self

Create new, default options.

source

pub fn whitespace(self, indent_str: impl Into<Cow<'static, str>>) -> Self

👎Deprecated since 0.8.1: use ‘indent’ method instead

deprecated. Use WriteOptions::indent instead.

Builder-style method to customize the whitespace.

By default, we indent with a single tab (“\t”).

The argument, may be either a 'static str or a String. You should prefer to use a 'static str where possible.

The string can contain any number of a single ASCII character, but must not contain multiple different characters. As an example, “\t\t” is fine, but “\t \t” is not, because it contains both tabs and spaces.

§Panics

Panics if the provided string is empty, or if it contains multiple different characters.

source

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

Customize the indent whitespace.

By default, we indent with a single tab (\t). You can use this method to specify alternative indent behaviour.

§Panics

Panics if the provided indent_char is not one of 0x09 (tab) or 0x20 (space).

§Example

Indenting with four spaces:

use norad::WriteOptions;
let options = WriteOptions::new().indent(WriteOptions::SPACE, 4);
source

pub fn quote_char(self, quote_style: QuoteChar) -> Self

Builder-style method to customize the XML declaration attribute definition quote char.

By default, we indent with double quotes.

The quote style is defined with a QuoteChar enum argument.

source

pub fn xml_options(&self) -> &XmlWriteOptions

Return a reference to XmlWriteOptions for use with the plist crate.

Trait Implementations§

source§

impl Clone for WriteOptions

source§

fn clone(&self) -> WriteOptions

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for WriteOptions

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for WriteOptions

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.