ExtensionFile

Struct ExtensionFile 

Source
pub struct ExtensionFile { /* private fields */ }
Available on crate feature parse only.
Expand description

A parsed and validated RawExtensions: a simple extensions file.

An ExtensionFile has a canonical Urn and a parsed set of SimpleExtensions data. It represents the extensions file as a whole.

Implementations§

Source§

impl ExtensionFile

Source

pub fn empty(urn: Urn) -> Self

Create a new, empty ExtensionFile with an empty set of SimpleExtensions.

Source

pub fn create(extensions: RawExtensions) -> Result<Self, SimpleExtensionsError>

Create an ExtensionFile from raw simple extension data.

Source

pub fn get_type(&self, name: &str) -> Option<&CustomType>

Get a type by name

Source

pub fn types(&self) -> impl Iterator<Item = &CustomType>

Get an iterator over all types in this extension

Source

pub fn urn(&self) -> &Urn

Returns the Urn` for this extension file.

Source

pub fn extension(&self) -> &SimpleExtensions

Get a reference to the underlying SimpleExtensions.

Source

pub fn into_raw(self) -> RawExtensions

Convert the parsed extension file back into the raw text representation by value.

Source

pub fn to_raw(&self) -> RawExtensions

Convert the parsed extension file back into the raw text representation by reference.

Source

pub fn read<R: Read>(reader: R) -> Result<Self, SimpleExtensionsError>

Read an extension file from a reader.

  • reader: any Read instance with the YAML content

Returns a parsed and validated ExtensionFile or an error.

Source

pub fn read_from_str<S: AsRef<str>>(s: S) -> Result<Self, SimpleExtensionsError>

Read an extension file from a string slice.

Trait Implementations§

Source§

impl Debug for ExtensionFile

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.