pub struct Map { /* private fields */ }
Expand description
Represents a created map.
Some methods require working with raw bytes. You may find libraries such as
plain
helpful.
Implementations
sourceimpl Map
impl Map
pub fn name(&self) -> &str
pub fn map_type(&self) -> MapType
sourcepub fn value_size(&self) -> u32
pub fn value_size(&self) -> u32
Value size in bytes
sourcepub fn lookup(&self, key: &[u8], flags: MapFlags) -> Result<Option<Vec<u8>>>
pub fn lookup(&self, key: &[u8], flags: MapFlags) -> Result<Option<Vec<u8>>>
Returns map value as Vec
of u8
.
key
must have exactly Map::key_size()
elements.
If the map is one of the per-cpu data structures, the function Map::lookup_percpu()
must be used.
sourcepub fn lookup_percpu(
&self,
key: &[u8],
flags: MapFlags
) -> Result<Option<Vec<Vec<u8>>>>
pub fn lookup_percpu(
&self,
key: &[u8],
flags: MapFlags
) -> Result<Option<Vec<Vec<u8>>>>
Returns one value per cpu as Vec
of Vec
of u8
for per per-cpu maps.
For normal maps, Map::lookup()
must be used.
sourcepub fn delete(&mut self, key: &[u8]) -> Result<()>
pub fn delete(&mut self, key: &[u8]) -> Result<()>
Deletes an element from the map.
key
must have exactly Map::key_size()
elements.
sourcepub fn lookup_and_delete(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>
pub fn lookup_and_delete(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>
Same as Map::lookup()
except this also deletes the key from the map.
Note that this operation is currently only implemented in the kernel for MapType::Queue
and MapType::Stack
.
key
must have exactly Map::key_size()
elements.
sourcepub fn update(
&mut self,
key: &[u8],
value: &[u8],
flags: MapFlags
) -> Result<()>
pub fn update(
&mut self,
key: &[u8],
value: &[u8],
flags: MapFlags
) -> Result<()>
Update an element.
key
must have exactly Map::key_size()
elements. value
must have exactly
Map::value_size()
elements.
For per-cpu maps, Map::update_percpu()
must be used.
sourcepub fn update_percpu(
&mut self,
key: &[u8],
values: &[Vec<u8>],
flags: MapFlags
) -> Result<()>
pub fn update_percpu(
&mut self,
key: &[u8],
values: &[Vec<u8>],
flags: MapFlags
) -> Result<()>
Update an element in an per-cpu map with one value per cpu.
key
must have exactly Map::key_size()
elements. value
must have one
element per cpu (see num_possible_cpus()
) with exactly Map::value_size()
elements each.
For per-cpu maps, Map::update_percpu()
must be used.
Auto Trait Implementations
impl RefUnwindSafe for Map
impl !Send for Map
impl !Sync for Map
impl Unpin for Map
impl UnwindSafe for Map
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more