Enum fastobo::ast::EntityFrame

source ·
pub enum EntityFrame {
    Typedef(Box<TypedefFrame>),
    Term(Box<TermFrame>),
    Instance(Box<InstanceFrame>),
}
Expand description

An entity frame, describing either a term, an instance, or a typedef.

Ordering

Serializer conventions dictate that frames should be Serialized first with [Typedef] frames, then [Term], and then [Instance], which is reflected here in the order of the variants.

Variants§

Implementations§

source§

impl EntityFrame

source

pub fn as_term(&self) -> Option<&TermFrame>

Return a reference to the TermFrame if the entity frame is one, or None.

Use this function in conjunction with Iterator::flat_map to extract all term frames from an iterator of EntityFrame references:

let doc = fastobo::from_file("tests/data/ms.obo").unwrap();
let terms: Vec<&TermFrame> = doc
    .entities()
    .iter()
    .flat_map(EntityFrame::as_term)
    .collect();
source

pub fn as_term_mut(&mut self) -> Option<&mut TermFrame>

Return a mutable reference to the TermFrame if the entity frame is one, or None.

source

pub fn as_typedef(&self) -> Option<&TypedefFrame>

Return a reference to the TypedefFrame if the entity frame is one, or None.

source

pub fn as_typedef_mut(&mut self) -> Option<&mut TypedefFrame>

Return a mutable reference to the TypedefFrame if the entity frame is one, or None.

source

pub fn as_instance(&self) -> Option<&InstanceFrame>

Return a reference to the InstanceFrame if the entity frame is one, or None.

source

pub fn as_instance_mut(&mut self) -> Option<&mut InstanceFrame>

Return a mutable reference to the InstanceFrame if the entity frame is one, or None.

source

pub fn name(&self) -> Result<&UnquotedString, CardinalityError>

Get the name of the entity, if exactly one is declared.

source

pub fn definition(&self) -> Result<&Definition, CardinalityError>

Get the definition of the entity, if exactly one is declared.

Trait Implementations§

source§

impl Clone for EntityFrame

source§

fn clone(&self) -> EntityFrame

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 EntityFrame

source§

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

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

impl Display for EntityFrame

source§

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

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

impl From<EntityFrame> for Frame

source§

fn from(frame: EntityFrame) -> Self

Converts to this type from the input type.
source§

impl From<InstanceFrame> for EntityFrame

source§

fn from(frame: InstanceFrame) -> Self

Converts to this type from the input type.
source§

impl From<TermFrame> for EntityFrame

source§

fn from(frame: TermFrame) -> Self

Converts to this type from the input type.
source§

impl From<TypedefFrame> for EntityFrame

source§

fn from(frame: TypedefFrame) -> Self

Converts to this type from the input type.
source§

impl<'i> FromPair<'i> for EntityFrame

source§

const RULE: Rule = Rule::EntityFrame

The production rule the pair is expected to be obtained from.
source§

unsafe fn from_pair_unchecked( pair: Pair<'i, Rule>, cache: &Cache ) -> Result<Self, SyntaxError>

Create a new instance from a Pair without checking the rule. Read more
source§

fn from_pair(pair: Pair<'i, Rule>, cache: &Cache) -> Result<Self, SyntaxError>

Create a new instance from a Pair.
source§

impl FromStr for EntityFrame

§

type Err = SyntaxError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for EntityFrame

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Identified for EntityFrame

source§

fn as_id(&self) -> &Ident

Get a reference to the identifier of the entity.
source§

fn as_id_mut(&mut self) -> &mut Ident

Get a mutable reference to the identifier of the entity.
source§

impl Orderable for EntityFrame

source§

fn sort(&mut self)

Sort the elements of the collection in the right serialization order. Read more
source§

fn is_sorted(&self) -> bool

Check if the collection is sorted in the right serialization order.
source§

impl PartialEq<EntityFrame> for EntityFrame

source§

fn eq(&self, other: &EntityFrame) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for EntityFrame

source§

impl StructuralEq for EntityFrame

source§

impl StructuralPartialEq for EntityFrame

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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<'i, T> FromSlice<'i> for Twhere T: FromStr,

§

type Err = <T as FromStr>::Err

The associated error which can be returned from parsing.
source§

fn from_slice(s: &'i str) -> Result<T, <T as FromSlice<'i>>::Err>

Parses a string slice s to return a value of this type.
source§

impl<T, U> Into<U> for Twhere 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 Twhere 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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.