Enum OM

Source
#[repr(u8)]
pub enum OM<'de, I> { OMI { int: Int<'de>, attrs: Vec<OMAttr<'de, I>>, }, OMF { float: f64, attrs: Vec<OMAttr<'de, I>>, }, OMSTR { string: Cow<'de, str>, attrs: Vec<OMAttr<'de, I>>, }, OMB { bytes: Cow<'de, [u8]>, attrs: Vec<OMAttr<'de, I>>, }, OMV { name: Cow<'de, str>, attrs: Vec<OMAttr<'de, I>>, }, OMS { cd: Cow<'de, str>, name: Cow<'de, str>, attrs: Vec<OMAttr<'de, I>>, }, OMA { applicant: I, arguments: SmallVec<I, 2>, attrs: Vec<OMAttr<'de, I>>, }, OMBIND { binder: I, variables: SmallVec<(Cow<'de, str>, Vec<OMAttr<'de, I>>), 2>, object: I, attrs: Vec<OMAttr<'de, I>>, }, OME { cdbase: Option<Cow<'de, str>>, cd: Cow<'de, str>, name: Cow<'de, str>, arguments: Vec<OMMaybeForeign<'de, I>>, attrs: Vec<OMAttr<'de, I>>, }, }
Expand description

Enum for deserializing from OpenMath. See see OMDeserializable for documentation and an example.

Note that there is no case for OMATTR - instead, every case has a Vec<OMAttr<’de, I>>, which is usually empty. Otherwise, we’d have to either deal with two separate types, or have the nonsensical case OMATTR(OMATTR(OMATTR(...),...),...), which would also require a Box-indirection (hence allocation), etc. since OMATTR is mostly used for metadata which the recipient might not even care about, or only care secondarily (compared to the actual OM-kind), having OMATTR be a separate case seems like bad API design. Also, empty Vecs are cheap.

Variants§

§

OMI

Integers in the mathematical sense, with no predefined range. They are “infinite precision” integers (also called “bignums” in computer algebra).

Fields

§int: Int<'de>
§attrs: Vec<OMAttr<'de, I>>
§

OMF

Double precision floating-point numbers following the IEEE 754-1985 standard.

Fields

§float: f64
§attrs: Vec<OMAttr<'de, I>>
§

OMSTR

A Unicode Character string. This also corresponds to “characters” in XML.

Fields

§string: Cow<'de, str>
§attrs: Vec<OMAttr<'de, I>>
§

OMB

A sequence of bytes.

Fields

§bytes: Cow<'de, [u8]>
§attrs: Vec<OMAttr<'de, I>>
§

OMV

A Variable must have a name which is a sequence of characters matching a regular expression, as described in Section 2.3.

(Note: We do not enforce that names are valid XML names;)

Fields

§name: Cow<'de, str>
§attrs: Vec<OMAttr<'de, I>>
§

OMS

A Symbol encodes three fields of information, a symbol name, a Content Dictionary name, and (optionally) a Content Dictionary base URI, The name of a symbol is a sequence of characters matching the regular expression described in Section 2.3. The Content Dictionary is the location of the definition of the symbol, consisting of a name (a sequence of characters matching the regular expression described in Section 2.3) and, optionally, a unique prefix called a cdbase which is used to disambiguate multiple Content Dictionaries of the same name. There are other properties of the symbol that are not explicit in these fields but whose values may be obtained by inspecting the Content Dictionary specified. These include the symbol definition, formal properties and examples and, optionally, a role which is a restriction on where the symbol may appear in an OpenMath object. The possible roles are described in Section 2.1.4.

Fields

§cd: Cow<'de, str>
§name: Cow<'de, str>
§attrs: Vec<OMAttr<'de, I>>
§

OMA

If $A_1,...,A_n\;(n>0)$ are OpenMath objects, then $\mathrm{application}(A_1,...,A_n)$ is an OpenMath application object. We call $A_1$ the function and $A_2$ to $A_n$ the arguments.

Fields

§applicant: I
§arguments: SmallVec<I, 2>
§attrs: Vec<OMAttr<'de, I>>
§

OMBIND

If $B$ and $C$ are OpenMath objects, and $v_1,...,v_n\;(n\geq0)$ are OpenMath variables or attributed variables, then $\mathrm{binding}(B,v_1,...,v_n,C)$ is an OpenMath binding object. $B$ is called the binder, $v_1,...,v_n$ are called variable bindings, and $C$ is called the body of the binding object above.

Fields

§binder: I
§variables: SmallVec<(Cow<'de, str>, Vec<OMAttr<'de, I>>), 2>
§object: I
§attrs: Vec<OMAttr<'de, I>>
§

OME

If $S$ is an OpenMath symbol and $A_1,...,A_n\;(n\geq0)$ are OpenMath objects or derived OpenMath objects, then $\mathrm{error}(S,A_1,...,A_n)$ is an OpenMath error object.

Fields

§cdbase: Option<Cow<'de, str>>
§cd: Cow<'de, str>
§name: Cow<'de, str>
§arguments: Vec<OMMaybeForeign<'de, I>>
§attrs: Vec<OMAttr<'de, I>>

Implementations§

Source§

impl<I> OM<'_, I>

Source

pub fn kind(&self) -> OMKind

Returns the OMKind of this OM, which of all practical purposes acts as a discriminant.

Trait Implementations§

Source§

impl<'de, I: Clone> Clone for OM<'de, I>

Source§

fn clone(&self) -> OM<'de, I>

Returns a duplicate 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<'de, I: Debug> Debug for OM<'de, I>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'de, I> Freeze for OM<'de, I>
where I: Freeze,

§

impl<'de, I> RefUnwindSafe for OM<'de, I>
where I: RefUnwindSafe,

§

impl<'de, I> Send for OM<'de, I>
where I: Send,

§

impl<'de, I> Sync for OM<'de, I>
where I: Sync,

§

impl<'de, I> Unpin for OM<'de, I>
where I: Unpin,

§

impl<'de, I> UnwindSafe for OM<'de, I>

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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>,

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.