Struct libbpf_rs::btf::types::Composite

source ·
pub struct Composite<'btf> {
    pub is_struct: bool,
    /* private fields */
}
Expand description

A Composite type, which can be one of a Struct or a Union.

Sometimes it’s not useful to distinguish them, in that case, one can use this type to inspect any of them.

Fields§

§is_struct: bool

Whether this type is a struct.

Implementations§

source§

impl<'btf> Composite<'btf>

source

pub fn is_empty(&self) -> bool

Whether this type has no members

source

pub fn len(&self) -> usize

How many members this Composite has

source

pub fn get(&self, index: usize) -> Option<CompositeMember<'btf>>

Get a CompositeMember at a given index

§Errors

This function returns None when the index is out of bounds.

source

pub fn iter( &'btf self, ) -> impl ExactSizeIterator<Item = CompositeMember<'btf>> + 'btf

Returns an iterator over the CompositeMember’s of the Composite

Methods from Deref<Target = 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> Debug for Composite<'btf>

source§

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

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

impl<'btf> Deref for Composite<'btf>

§

type Target = BtfType<'btf>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'btf> From<Struct<'btf>> for Composite<'btf>

source§

fn from(s: Struct<'btf>) -> Self

Converts to this type from the input type.
source§

impl<'btf> From<Union<'btf>> for Composite<'btf>

source§

fn from(s: Union<'btf>) -> Self

Converts to this type from the input type.
source§

impl<'btf> HasSize<'btf> for Composite<'btf>

source§

fn size(&self) -> usize

The size of the described type.
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<Composite<'btf>> for Struct<'btf>

§

type Error = Composite<'btf>

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

fn try_from(value: Composite<'btf>) -> Result<Self, Self::Error>

Performs the conversion.
source§

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

§

type Error = Composite<'btf>

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

fn try_from(value: Composite<'btf>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'btf> Freeze for Composite<'btf>

§

impl<'btf> RefUnwindSafe for Composite<'btf>

§

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

§

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

§

impl<'btf> Unpin for Composite<'btf>

§

impl<'btf> UnwindSafe for Composite<'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, 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.