pub struct EbpfBufferPtr<'a> { /* private fields */ }Expand description
Wraps a pointer to buffer used in eBPF runtime, such as an eBPF maps
entry. The referenced data may be access from multiple threads in parallel,
which makes it unsafe to access it using standard Rust types.
EbpfBufferPtr allows to access these buffers safely. It may be used to
reference either a whole VMO allocated for and eBPF map or individual
elements of that VMO (see slice()). The address and the size of the
buffer are always 8-byte aligned.
Implementations§
Source§impl<'a> EbpfBufferPtr<'a>
impl<'a> EbpfBufferPtr<'a>
pub const ALIGNMENT: usize = 8usize
Sourcepub unsafe fn new(ptr: *mut u8, size: usize) -> Self
pub unsafe fn new(ptr: *mut u8, size: usize) -> Self
Creates a new EbpfBufferPtr from the specified pointer. ptr must be
8-byte aligned. size must be multiple of 8.
§Safety
Caller must ensure that the buffer referenced by ptr is valid for
lifetime 'a.
Sourcepub fn get_ptr<T>(&self, offset: usize) -> Option<EbpfPtr<'a, T>>
pub fn get_ptr<T>(&self, offset: usize) -> Option<EbpfPtr<'a, T>>
Returns a pointer to a value of type T at the specified offset.
Sourcepub fn slice(&self, range: impl RangeBounds<usize>) -> Option<Self>
pub fn slice(&self, range: impl RangeBounds<usize>) -> Option<Self>
Returns pointer to the specified range in the buffer. Range bounds must be multiple of 8.
Sourcepub fn store(&self, data: &[u8])
pub fn store(&self, data: &[u8])
Stores data in the buffer. data must be the same size as the
buffer.
Sourcepub fn store_padded(&self, data: &[u8])
pub fn store_padded(&self, data: &[u8])
Stores data at the head of the buffer. If data is not multiple of 8
then it’s padded at the end with zeros.
Trait Implementations§
Source§impl<'a> Clone for EbpfBufferPtr<'a>
impl<'a> Clone for EbpfBufferPtr<'a>
Source§fn clone(&self) -> EbpfBufferPtr<'a>
fn clone(&self) -> EbpfBufferPtr<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more