Record

Struct Record 

Source
pub struct Record<'a> { /* private fields */ }
Expand description

An immutable reference to a TableGen record.

This reference cannot outlive the RecordKeeper from which it is borrowed.

Implementations§

Source§

impl<'a> Record<'a>

Source

pub unsafe fn from_raw(ptr: TableGenRecordRef) -> Record<'a>

Creates a record from a raw object.

§Safety

The raw object must be valid.

Source

pub fn name(self) -> Result<&'a str, Error>

Returns the name of the record.

§Errors

Returns an error if the name is not a valid UTF-8 string.

Source

pub fn bits_value(self, name: &str) -> Result<Vec<bool>, Error>

Returns the field with the given name converted to a Vec<bool> if this field is of type BitsInit.

Source

pub fn code_value(self, name: &str) -> Result<String, Error>

Returns the field with the given name converted to a String if this field is of type StringInit.

Note that this copies the string into a new string.

Source

pub fn code_str_value(self, name: &str) -> Result<&'a str, Error>

Returns the field with the given name converted to a &str if this field is of type StringInit.

Source

pub fn string_value(self, name: &str) -> Result<String, Error>

Returns the field with the given name converted to a String if this field is of type StringInit.

Note that this copies the string into a new string.

Source

pub fn value<'n>(self, name: &'n str) -> Result<RecordValue<'a>, Error>

Returns a RecordValue for the field with the given name.

Source

pub fn anonymous(self) -> bool

Returns true if the record is anonymous.

Source

pub fn subclass_of(self, class: &str) -> bool

Returns true if the record is a subclass of the class with the given name.

Source

pub fn values(self) -> RecordValueIter<'a>

Returns an iterator over the fields of the record.

The iterator yields RecordValue structs

Source

pub fn has_field(self, name: &str) -> bool

Returns true if the record has a field with the given name.

Source

pub fn field_type(self, name: &str) -> Option<Type>

Returns the TableGenRecTyKind of the field with the given name, or None if the field does not exist.

Source

pub fn dump(self)

Dumps the record to stderr (for debugging).

Source

pub fn num_template_args(self) -> usize

Returns the number of template arguments.

Source

pub fn template_arg_name(self, index: usize) -> Option<&'a str>

Returns the template argument name at the given index.

Source

pub fn template_args(self) -> TemplateArgIter<'a>

Returns an iterator over the template argument names.

Source

pub fn num_super_classes(self) -> usize

Returns the number of direct super classes.

Source

pub fn super_class(self, index: usize) -> Option<Record<'a>>

Returns the super class at the given index.

Source

pub fn direct_super_classes(self) -> SuperClassIter<'a>

Returns an iterator over the direct super classes.

Source

pub fn int_value(self, name: &str) -> Result<i64, Error>

Returns the integer value of the field with the given name.

Source

pub fn str_value(self, name: &str) -> Result<&'a str, Error>

Returns the string value of the field with the given name as a &str.

Source

pub fn bit_value(self, name: &str) -> Result<bool, Error>

Returns the bit (boolean) value of the field with the given name.

Source

pub fn def_value(self, name: &str) -> Result<Record<'a>, Error>

Returns the def value of the field with the given name as a Record.

Source

pub fn dag_value(self, name: &str) -> Result<DagInit<'a>, Error>

Returns the dag value of the field with the given name.

Source

pub fn bits_init_value(self, name: &str) -> Result<BitsInit<'a>, Error>

Returns the bits init of the field with the given name.

Source

pub fn list_init_value(self, name: &str) -> Result<ListInit<'a>, Error>

Returns the list init of the field with the given name.

Source

pub fn list_of_defs_value(self, name: &str) -> Result<Vec<Record<'a>>, Error>

Returns the list-of-defs value of the field with the given name.

Source

pub fn list_of_ints_value(self, name: &str) -> Result<Vec<i64>, Error>

Returns the list-of-ints value of the field with the given name.

Source

pub fn list_of_strings_value(self, name: &str) -> Result<Vec<&'a str>, Error>

Returns the list-of-strings value of the field with the given name.

Source

pub fn optional_str_value(self, name: &str) -> Result<Option<&'a str>, Error>

Returns the optional string value of the field, or None if unset.

Returns Err if the field does not exist or is not a string/unset.

Source

pub fn optional_def_value(self, name: &str) -> Option<Record<'a>>

Returns the optional def value of the field, or None if unset.

Source

pub fn is_value_unset(self, name: &str) -> bool

Returns true if the named field exists and has an unset value (?).

Source

pub fn is_class(self) -> bool

Returns true if this record is a class definition (not a def).

Source

pub fn def_init(self) -> DefInit<'a>

Returns the DefInit for this record.

Source

pub fn id(self) -> u32

Returns the unique numeric ID of this record.

Source

pub fn name_init(self) -> TypedInit<'a>

Returns the name as a raw TypedInit.

Source

pub fn has_direct_super_class(self, super_class: Record<'a>) -> bool

Returns true if the given record is a direct superclass of this record.

Source

pub fn num_type_classes(self) -> usize

Returns the number of classes in this record’s type.

Source

pub fn type_class(self, index: usize) -> Option<Record<'a>>

Returns the class at the given index in this record’s type.

Source

pub fn type_is_subclass_of(self, class: Record<'a>) -> bool

Returns true if this record’s type is a subclass of the given class.

Trait Implementations§

Source§

impl<'a> Clone for Record<'a>

Source§

fn clone(&self) -> Record<'a>

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 Debug for Record<'_>

Source§

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

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

impl Display for Record<'_>

Source§

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

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

impl<'a> From<DefInit<'a>> for Record<'a>

Source§

fn from(value: DefInit<'a>) -> Self

Converts to this type from the input type.
Source§

impl Hash for Record<'_>

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<'a> PartialEq for Record<'a>

Source§

fn eq(&self, other: &Record<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl SourceLoc for Record<'_>

Source§

fn source_location(self) -> SourceLocation

Returns the source location.
Source§

impl<'a> TryFrom<RecordValue<'a>> for Record<'a>

Source§

type Error = SourceError<TableGenError>

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

fn try_from(record_value: RecordValue<'a>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<TypedInit<'a>> for Record<'a>

Source§

type Error = SourceError<TableGenError>

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

fn try_from(value: TypedInit<'a>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> Copy for Record<'a>

Source§

impl<'a> Eq for Record<'a>

Source§

impl<'a> StructuralPartialEq for Record<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Record<'a>

§

impl<'a> RefUnwindSafe for Record<'a>

§

impl<'a> !Send for Record<'a>

§

impl<'a> !Sync for Record<'a>

§

impl<'a> Unpin for Record<'a>

§

impl<'a> UnwindSafe for Record<'a>

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.