pub struct NetnodeMut<'db> { /* private fields */ }Expand description
A write cursor on one netnode, from Database::netnode_mut.
Holds the database exclusively (&mut Database) and is read-capable: the scalar Netnode
accessors are inherent here, so a read-modify-write stays on one cursor. Not Copy, and not
obtainable from a borrowing Netnode.
Implementations§
Source§impl NetnodeMut<'_>
impl NetnodeMut<'_>
Sourcepub fn altval(&self, index: u64) -> u64
pub fn altval(&self, index: u64) -> u64
The altval at index, or 0 when unset (the SDK does not distinguish the two).
Sourcepub fn supval(&self, index: u64) -> Option<Vec<u8>>
pub fn supval(&self, index: u64) -> Option<Vec<u8>>
The supval byte object at index, or None if unset.
Sourcepub fn hash(&self, key: &str) -> Option<Vec<u8>>
pub fn hash(&self, key: &str) -> Option<Vec<u8>>
The hash value for key as raw bytes, or None if the key is unset.
Sourcepub fn hash_integer(&self, key: &str) -> u64
pub fn hash_integer(&self, key: &str) -> u64
The hash value for key decoded as an integer, or 0 when unset.
Sourcepub fn blob(&self) -> Option<Vec<u8>>
pub fn blob(&self) -> Option<Vec<u8>>
The default blob (start = 0), or None if the node holds none.
Sourcepub fn blob_size(&self) -> usize
pub fn blob_size(&self) -> usize
The byte length of the default blob (start = 0), or 0 when absent.
Sourcepub fn altvals(&self) -> Altvals<'_> ⓘ
pub fn altvals(&self) -> Altvals<'_> ⓘ
Lazily iterate the altval array as (index, value) pairs, in ascending index order.
Sourcepub fn supvals(&self) -> Supvals<'_> ⓘ
pub fn supvals(&self) -> Supvals<'_> ⓘ
Lazily iterate the supval array as (index, bytes) pairs, in ascending index order.
Sourcepub fn hash_entries(&self) -> HashEntries<'_> ⓘ
pub fn hash_entries(&self) -> HashEntries<'_> ⓘ
Lazily iterate the hash as (key, bytes) pairs, in lexical key order.
Sourcepub fn get_serde<T: DeserializeOwned>(&self, key: &str) -> Option<T>
pub fn get_serde<T: DeserializeOwned>(&self, key: &str) -> Option<T>
The serde value under hash key, or None if absent or undecodable.
Sourcepub fn get_serde_at<T: DeserializeOwned>(&self, index: u64) -> Option<T>
pub fn get_serde_at<T: DeserializeOwned>(&self, index: u64) -> Option<T>
The serde value in the blob at index, or None if absent or undecodable.
Sourcepub fn tag(&mut self, tag: Tag) -> TaggedNetnodeMut<'_>
pub fn tag(&mut self, tag: Tag) -> TaggedNetnodeMut<'_>
A read-write view of this node’s arrays under tag, for reaching non-default tags.
Sourcepub fn set_hash_integer(&mut self, key: &str, value: u64) -> Result<()>
pub fn set_hash_integer(&mut self, key: &str, value: u64) -> Result<()>
Set the hash value for key to an integer.
§Errors
Error::WriteRejected if the kernel rejects the write.
Sourcepub fn set_blob(&mut self, value: &[u8]) -> Result<()>
pub fn set_blob(&mut self, value: &[u8]) -> Result<()>
Store the default blob (start = 0), replacing any existing one.
§Errors
Error::WriteRejected if the kernel rejects the write.
Sourcepub fn rename(&mut self, name: &str) -> Result<()>
pub fn rename(&mut self, name: &str) -> Result<()>
Rename the node (an empty name clears it).
§Errors
Error::WriteRejected if the name is already taken.
Sourcepub fn clear_value(&mut self) -> bool
pub fn clear_value(&mut self) -> bool
Delete the node value, returning whether one was set.
Sourcepub fn remove_altval(&mut self, index: u64) -> bool
pub fn remove_altval(&mut self, index: u64) -> bool
Delete the altval at index, returning whether it was set.
Sourcepub fn clear_altvals(&mut self) -> bool
pub fn clear_altvals(&mut self) -> bool
Delete every altval, returning whether any were set.
Sourcepub fn remove_supval(&mut self, index: u64) -> bool
pub fn remove_supval(&mut self, index: u64) -> bool
Delete the supval byte object at index, returning whether it was set.
Sourcepub fn clear_supvals(&mut self) -> bool
pub fn clear_supvals(&mut self) -> bool
Delete every supval byte object, returning whether any were set.
Sourcepub fn remove_hash(&mut self, key: &str) -> bool
pub fn remove_hash(&mut self, key: &str) -> bool
Delete the hash value for key, returning whether it was set.
Sourcepub fn clear_hash(&mut self) -> bool
pub fn clear_hash(&mut self) -> bool
Delete every hash entry, returning whether any were set.
Sourcepub fn remove_blob(&mut self) -> bool
pub fn remove_blob(&mut self) -> bool
Delete the default blob (start = 0), returning whether one was stored.
The kernel answers with the number of slots it freed, which is the blob’s storage footprint rather than anything the caller chose, so only its sign is surfaced.
Sourcepub fn set_value<'a>(
&mut self,
value: impl TryInto<NetnodeBytes<'a>, Error: Into<NetnodeBytesError>>,
) -> Result<()>
pub fn set_value<'a>( &mut self, value: impl TryInto<NetnodeBytes<'a>, Error: Into<NetnodeBytesError>>, ) -> Result<()>
Set the node value, from 1 to NetnodeBytes::MAX_SIZE bytes.
§Errors
Error::InvalidNetnodeBytes if value is empty or exceeds NetnodeBytes::MAX_SIZE,
or Error::WriteRejected if the kernel rejects the write.
Sourcepub fn set_supval<'a>(
&mut self,
index: u64,
value: impl TryInto<NetnodeBytes<'a>, Error: Into<NetnodeBytesError>>,
) -> Result<()>
pub fn set_supval<'a>( &mut self, index: u64, value: impl TryInto<NetnodeBytes<'a>, Error: Into<NetnodeBytesError>>, ) -> Result<()>
Set the supval byte object at index, from 1 to NetnodeBytes::MAX_SIZE bytes.
§Errors
Error::InvalidNetnodeBytes if value is empty or exceeds NetnodeBytes::MAX_SIZE,
or Error::WriteRejected if the kernel rejects the write.
Sourcepub fn set_hash<'a>(
&mut self,
key: &str,
value: impl TryInto<NetnodeBytes<'a>, Error: Into<NetnodeBytesError>>,
) -> Result<()>
pub fn set_hash<'a>( &mut self, key: &str, value: impl TryInto<NetnodeBytes<'a>, Error: Into<NetnodeBytesError>>, ) -> Result<()>
Set the hash value for key to raw bytes, from 1 to NetnodeBytes::MAX_SIZE bytes.
§Errors
Error::InvalidNetnodeBytes if value is empty or exceeds NetnodeBytes::MAX_SIZE,
or Error::WriteRejected if the kernel rejects the write.
Sourcepub fn put<T: Persist>(&mut self, key: &str, value: &T) -> Result<()>
pub fn put<T: Persist>(&mut self, key: &str, value: &T) -> Result<()>
Store a typed value under hash key.
The write half of get; the value is serialized through Persist and
stored in the hash.
§Errors
Error::WriteRejected if the kernel rejects the write.
Sourcepub fn remove(&mut self, key: &str) -> bool
pub fn remove(&mut self, key: &str) -> bool
Remove the typed value (or any hash bytes) under key, returning whether it was set.
The inverse of put.
Sourcepub fn put_serde<T: Serialize>(&mut self, key: &str, value: &T) -> Result<()>
pub fn put_serde<T: Serialize>(&mut self, key: &str, value: &T) -> Result<()>
Store value under hash key via serde (postcard); capped at 1024 bytes.
§Errors
Error::SerializeFailed on an encoding failure, or Error::WriteRejected if the kernel
rejects the write (e.g. over the cap).
Sourcepub fn put_serde_at<T: Serialize>(
&mut self,
index: u64,
value: &T,
) -> Result<()>
pub fn put_serde_at<T: Serialize>( &mut self, index: u64, value: &T, ) -> Result<()>
Store value in the blob at index via serde (postcard); uncapped.
§Errors
Error::SerializeFailed on an encoding failure, or Error::WriteRejected if the kernel
rejects the write.