pub struct Consts {
    pub consts: Vec<Const>,
}
Expand description

Wrapper around a vector of Const with some helper functions.

Fields§

§consts: Vec<Const>

Implementations§

source§

impl Consts

source

pub fn new(consts: Vec<Const>) -> Self

source

pub fn find_sysno(&self, name: &str, arch: &Arch) -> Option<usize>

Try and resolve a system call number by name, like write

source

pub fn consts(&self) -> Iter<'_, Const>

Iterate over all the consts

source

pub fn push(&mut self, c: Const)

Push new value without checking if this element is new

source

pub fn find_name_arch(&self, name: &str, arch: &Arch) -> Option<&Const>

Find value based on name and architecture

source

pub fn get_arch_from_path(file: &Path) -> Result<Option<Arch>, Error>

Architecture can be specified on the filename, like: <name>_amd64.const. This function tries to extract it.

source

pub fn create_from_file(&mut self, p: &Path) -> Result<(), Error>

Parse constants from file

source

pub fn create_from_str(s: &str, arch: Option<Arch>) -> Result<Vec<Const>, Error>

Create constants from string

source

pub fn add_if_new(&mut self, c: Const) -> bool

Same as Self::push, but only add if the element is unique

source

pub fn add_vec(&mut self, consts: Vec<Const>) -> usize

Add from a vector, uses Self::add_if_new on each element

source

pub fn filter_arch(&mut self, arch: &Arch)

Remove all consts not relevant for the specified architecture.

Not necessary, but can be used to save memory.

Trait Implementations§

source§

impl Clone for Consts

source§

fn clone(&self) -> Consts

Returns a copy 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 Consts

source§

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

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

impl Default for Consts

source§

fn default() -> Consts

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Consts

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for Consts

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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

§

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

§

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

§

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,