pub struct MapHandle { /* private fields */ }
Expand description
A handle to a map. Handles can be duplicated and dropped.
While possible to created directly, in many cases it is
useful to create such a handle from an existing Map
:
let map: &Map = get_map();
let map_handle = MapHandle::try_from(map).unwrap();
Some methods require working with raw bytes. You may find libraries such as
plain
helpful.
Implementations§
Source§impl MapHandle
impl MapHandle
Sourcepub fn create<T: AsRef<OsStr>>(
map_type: MapType,
name: Option<T>,
key_size: u32,
value_size: u32,
max_entries: u32,
opts: &bpf_map_create_opts,
) -> Result<Self>
pub fn create<T: AsRef<OsStr>>( map_type: MapType, name: Option<T>, key_size: u32, value_size: u32, max_entries: u32, opts: &bpf_map_create_opts, ) -> Result<Self>
Create a bpf map whose data is not managed by libbpf.
Sourcepub fn from_pinned_path<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn from_pinned_path<P: AsRef<Path>>(path: P) -> Result<Self>
Sourcepub fn from_map_id(id: u32) -> Result<Self>
pub fn from_map_id(id: u32) -> Result<Self>
Open a loaded map from its map id.
Sourcepub fn freeze(&self) -> Result<()>
pub fn freeze(&self) -> Result<()>
Freeze the map as read-only from user space.
Entries from a frozen map can no longer be updated or deleted with the bpf() system call. This operation is not reversible, and the map remains immutable from user space until its destruction. However, read and write permissions for BPF programs to the map remain unchanged.
Trait Implementations§
Source§impl AsFd for MapHandle
impl AsFd for MapHandle
Source§fn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more
Source§impl MapCore for MapHandle
impl MapCore for MapHandle
Source§fn value_size(&self) -> u32
fn value_size(&self) -> u32
Retrieve the size of the map’s values.
Source§fn lookup_bloom_filter(&self, value: &[u8]) -> Result<bool>
fn lookup_bloom_filter(&self, value: &[u8]) -> Result<bool>
Returns if the given value is likely present in bloom_filter as
bool
. Read moreSource§fn delete_batch(
&self,
keys: &[u8],
count: u32,
elem_flags: MapFlags,
flags: MapFlags,
) -> Result<()>
fn delete_batch( &self, keys: &[u8], count: u32, elem_flags: MapFlags, flags: MapFlags, ) -> Result<()>
Deletes many elements in batch mode from the map. Read more
Source§fn lookup_and_delete(&self, key: &[u8]) -> Result<Option<Vec<u8>>>
fn lookup_and_delete(&self, key: &[u8]) -> Result<Option<Vec<u8>>>
Same as
Self::lookup()
except this also deletes the key from the map. Read moreSource§fn update(&self, key: &[u8], value: &[u8], flags: MapFlags) -> Result<()>
fn update(&self, key: &[u8], value: &[u8], flags: MapFlags) -> Result<()>
Update an element. Read more
Auto Trait Implementations§
impl Freeze for MapHandle
impl RefUnwindSafe for MapHandle
impl Send for MapHandle
impl Sync for MapHandle
impl Unpin for MapHandle
impl UnwindSafe for MapHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more