pub struct Definition {
    pub namespace: Vec<String>,
    pub name: String,
    pub id: u32,
    pub params: Vec<Parameter>,
    pub ty: Type,
    pub category: Category,
}
Expand description

A Type Language definition.

Fields§

§namespace: Vec<String>

The namespace components of the definition. This list will be empty if the name of the definition belongs to the global namespace.

§name: String

The name of this definition. Also known as “predicate” or “method”.

§id: u32

The numeric identifier of this definition.

If a definition has an identifier, it overrides this value. Otherwise, the identifier is inferred from the definition.

§params: Vec<Parameter>

A possibly-empty list of parameters this definition has.

§ty: Type

The type to which this definition belongs to.

§category: Category

The category to which this definition belongs to.

Implementations§

source§

impl Definition

source

pub fn full_name(&self) -> String

Convenience function to format both the namespace and name back into a single string.

Trait Implementations§

source§

impl Debug for Definition

source§

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

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

impl Display for Definition

source§

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

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

impl FromStr for Definition

source§

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

Parses a Type Language definition.

Examples
use grammers_tl_parser::tl::Definition;

assert!("sendMessage chat_id:int message:string = Message".parse::<Definition>().is_ok());
§

type Err = ParseError

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

impl PartialEq for Definition

source§

fn eq(&self, other: &Definition) -> 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 StructuralPartialEq for Definition

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