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>
impl<'a> Record<'a>
Sourcepub unsafe fn from_raw(ptr: TableGenRecordRef) -> Record<'a>
pub unsafe fn from_raw(ptr: TableGenRecordRef) -> Record<'a>
Sourcepub fn code_value(self, name: &str) -> Result<String, Error>
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.
Sourcepub fn code_str_value(self, name: &str) -> Result<&'a str, Error>
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.
Sourcepub fn string_value(self, name: &str) -> Result<String, Error>
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.
Sourcepub fn value<'n>(self, name: &'n str) -> Result<RecordValue<'a>, Error>
pub fn value<'n>(self, name: &'n str) -> Result<RecordValue<'a>, Error>
Returns a RecordValue for the field with the given name.
Sourcepub fn subclass_of(self, class: &str) -> bool
pub fn subclass_of(self, class: &str) -> bool
Returns true if the record is a subclass of the class with the given name.
Sourcepub fn values(self) -> RecordValueIter<'a> ⓘ
pub fn values(self) -> RecordValueIter<'a> ⓘ
Returns an iterator over the fields of the record.
The iterator yields RecordValue structs
Sourcepub fn has_field(self, name: &str) -> bool
pub fn has_field(self, name: &str) -> bool
Returns true if the record has a field with the given name.
Sourcepub fn field_type(self, name: &str) -> Option<Type>
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.
Sourcepub fn num_template_args(self) -> usize
pub fn num_template_args(self) -> usize
Returns the number of template arguments.
Sourcepub fn template_arg_name(self, index: usize) -> Option<&'a str>
pub fn template_arg_name(self, index: usize) -> Option<&'a str>
Returns the template argument name at the given index.
Sourcepub fn template_args(self) -> TemplateArgIter<'a> ⓘ
pub fn template_args(self) -> TemplateArgIter<'a> ⓘ
Returns an iterator over the template argument names.
Sourcepub fn num_super_classes(self) -> usize
pub fn num_super_classes(self) -> usize
Returns the number of direct super classes.
Sourcepub fn super_class(self, index: usize) -> Option<Record<'a>>
pub fn super_class(self, index: usize) -> Option<Record<'a>>
Returns the super class at the given index.
Sourcepub fn direct_super_classes(self) -> SuperClassIter<'a> ⓘ
pub fn direct_super_classes(self) -> SuperClassIter<'a> ⓘ
Returns an iterator over the direct super classes.
Sourcepub fn int_value(self, name: &str) -> Result<i64, Error>
pub fn int_value(self, name: &str) -> Result<i64, Error>
Returns the integer value of the field with the given name.
Sourcepub fn str_value(self, name: &str) -> Result<&'a str, Error>
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.
Sourcepub fn bit_value(self, name: &str) -> Result<bool, Error>
pub fn bit_value(self, name: &str) -> Result<bool, Error>
Returns the bit (boolean) value of the field with the given name.
Sourcepub fn def_value(self, name: &str) -> Result<Record<'a>, Error>
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.
Sourcepub fn dag_value(self, name: &str) -> Result<DagInit<'a>, Error>
pub fn dag_value(self, name: &str) -> Result<DagInit<'a>, Error>
Returns the dag value of the field with the given name.
Sourcepub fn bits_init_value(self, name: &str) -> Result<BitsInit<'a>, Error>
pub fn bits_init_value(self, name: &str) -> Result<BitsInit<'a>, Error>
Returns the bits init of the field with the given name.
Sourcepub fn list_init_value(self, name: &str) -> Result<ListInit<'a>, Error>
pub fn list_init_value(self, name: &str) -> Result<ListInit<'a>, Error>
Returns the list init of the field with the given name.
Sourcepub fn list_of_defs_value(self, name: &str) -> Result<Vec<Record<'a>>, Error>
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.
Sourcepub fn list_of_ints_value(self, name: &str) -> Result<Vec<i64>, Error>
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.
Sourcepub fn list_of_strings_value(self, name: &str) -> Result<Vec<&'a str>, Error>
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.
Sourcepub fn optional_str_value(self, name: &str) -> Result<Option<&'a str>, Error>
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.
Sourcepub fn optional_def_value(self, name: &str) -> Option<Record<'a>>
pub fn optional_def_value(self, name: &str) -> Option<Record<'a>>
Returns the optional def value of the field, or None if unset.
Sourcepub fn is_value_unset(self, name: &str) -> bool
pub fn is_value_unset(self, name: &str) -> bool
Returns true if the named field exists and has an unset value (?).
Sourcepub fn has_direct_super_class(self, super_class: Record<'a>) -> bool
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.
Sourcepub fn num_type_classes(self) -> usize
pub fn num_type_classes(self) -> usize
Returns the number of classes in this record’s type.
Sourcepub fn type_class(self, index: usize) -> Option<Record<'a>>
pub fn type_class(self, index: usize) -> Option<Record<'a>>
Returns the class at the given index in this record’s type.
Sourcepub fn type_is_subclass_of(self, class: Record<'a>) -> bool
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.