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
impl EntityFrame
sourcepub fn as_term(&self) -> Option<&TermFrame>
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();
sourcepub fn as_term_mut(&mut self) -> Option<&mut TermFrame>
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
.
sourcepub fn as_typedef(&self) -> Option<&TypedefFrame>
pub fn as_typedef(&self) -> Option<&TypedefFrame>
Return a reference to the TypedefFrame
if the entity frame is one, or None
.
sourcepub fn as_typedef_mut(&mut self) -> Option<&mut TypedefFrame>
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
.
sourcepub fn as_instance(&self) -> Option<&InstanceFrame>
pub fn as_instance(&self) -> Option<&InstanceFrame>
Return a reference to the InstanceFrame
if the entity frame is one, or None
.
sourcepub fn as_instance_mut(&mut self) -> Option<&mut InstanceFrame>
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
.
sourcepub fn name(&self) -> Result<&UnquotedString, CardinalityError>
pub fn name(&self) -> Result<&UnquotedString, CardinalityError>
Get the name of the entity, if exactly one is declared.
sourcepub fn definition(&self) -> Result<&Definition, CardinalityError>
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
impl Clone for EntityFrame
source§fn clone(&self) -> EntityFrame
fn clone(&self) -> EntityFrame
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for EntityFrame
impl Debug for EntityFrame
source§impl Display for EntityFrame
impl Display for EntityFrame
source§impl From<EntityFrame> for Frame
impl From<EntityFrame> for Frame
source§fn from(frame: EntityFrame) -> Self
fn from(frame: EntityFrame) -> Self
source§impl From<InstanceFrame> for EntityFrame
impl From<InstanceFrame> for EntityFrame
source§fn from(frame: InstanceFrame) -> Self
fn from(frame: InstanceFrame) -> Self
source§impl From<TermFrame> for EntityFrame
impl From<TermFrame> for EntityFrame
source§impl From<TypedefFrame> for EntityFrame
impl From<TypedefFrame> for EntityFrame
source§fn from(frame: TypedefFrame) -> Self
fn from(frame: TypedefFrame) -> Self
source§impl<'i> FromPair<'i> for EntityFrame
impl<'i> FromPair<'i> for EntityFrame
source§impl FromStr for EntityFrame
impl FromStr for EntityFrame
source§impl Hash for EntityFrame
impl Hash for EntityFrame
source§impl Identified for EntityFrame
impl Identified for EntityFrame
source§impl Orderable for EntityFrame
impl Orderable for EntityFrame
source§impl PartialEq<EntityFrame> for EntityFrame
impl PartialEq<EntityFrame> for EntityFrame
source§fn eq(&self, other: &EntityFrame) -> bool
fn eq(&self, other: &EntityFrame) -> bool
self
and other
values to be equal, and is used
by ==
.