Struct libbpf_rs::btf::BtfType

source ·
pub struct BtfType<'btf> { /* private fields */ }
Expand description

An undiscriminated btf type

The btf_type_match can be used to match on the variants of this type as if it was a rust enum.

You can also use the TryFrom trait to convert to any of the possible types.

Implementations§

source§

impl<'btf> BtfType<'btf>

source

pub fn type_id(&self) -> TypeId

This type’s type id.

source

pub fn name(&self) -> Option<&'btf CStr>

This type’s name.

source

pub fn kind(&self) -> BtfKind

This type’s kind.

source

pub fn is_mod(&self) -> bool

Whether this represent’s a modifier.

source

pub fn is_any_enum(&self) -> bool

Whether this represents any kind of enum.

source

pub fn is_core_compat(&self, other: &Self) -> bool

Whether this btf type is core compatible to other.

source

pub fn is_composite(&self) -> bool

Whether this type represents a composite type (struct/union).

source

pub fn next_type(&self) -> Option<Self>

If this type implements ReferencesType, returns the type it references.

source

pub fn skip_mods_and_typedefs(&self) -> Self

Given a type, follows the refering type ids until it finds a type that isn’t a modifier or a BtfKind::Typedef.

See is_mod.

source

pub fn alignment(&self) -> Result<NonZeroUsize>

Returns the alignment of this type, if this type points to some modifier or typedef, those will be skipped until the underlying type (with an alignment) is found.

See skip_mods_and_typedefs.

Trait Implementations§

source§

impl<'btf> Clone for BtfType<'btf>

source§

fn clone(&self) -> BtfType<'btf>

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 BtfType<'_>

source§

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

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

impl<'btf> TryFrom<BtfType<'btf>> for Array<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for Composite<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for Const<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for DataSec<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for DeclTag<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for Enum<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for Enum64<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for Float<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for Func<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for FuncProto<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for Fwd<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for Int<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for Ptr<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for Restrict<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for Struct<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for TypeTag<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for Typedef<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for Union<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for Var<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for Void<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> TryFrom<BtfType<'btf>> for Volatile<'btf>

§

type Error = BtfType<'btf>

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

fn try_from(t: BtfType<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'btf> Copy for BtfType<'btf>

Auto Trait Implementations§

§

impl<'btf> Freeze for BtfType<'btf>

§

impl<'btf> RefUnwindSafe for BtfType<'btf>

§

impl<'btf> !Send for BtfType<'btf>

§

impl<'btf> !Sync for BtfType<'btf>

§

impl<'btf> Unpin for BtfType<'btf>

§

impl<'btf> UnwindSafe for BtfType<'btf>

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.