Skip to main content

NetnodeMut

Struct NetnodeMut 

Source
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<'_>

Source

pub const fn id(&self) -> NodeId

The id this handle is keyed by.

Source

pub fn name(&self) -> Option<String>

The node’s name, or None if it is unnamed.

Source

pub fn exists(&self) -> bool

Whether the node exists (carries a name or any data).

Source

pub fn value(&self) -> Option<Vec<u8>>

The node value as raw bytes, or None if unset.

Source

pub fn value_str(&self) -> Option<String>

The node value as a string, or None if unset.

Source

pub fn altval(&self, index: u64) -> u64

The altval at index, or 0 when unset (the SDK does not distinguish the two).

Source

pub fn supval(&self, index: u64) -> Option<Vec<u8>>

The supval byte object at index, or None if unset.

Source

pub fn hash(&self, key: &str) -> Option<Vec<u8>>

The hash value for key as raw bytes, or None if the key is unset.

Source

pub fn hash_integer(&self, key: &str) -> u64

The hash value for key decoded as an integer, or 0 when unset.

Source

pub fn blob(&self) -> Option<Vec<u8>>

The default blob (start = 0), or None if the node holds none.

Source

pub fn blob_size(&self) -> usize

The byte length of the default blob (start = 0), or 0 when absent.

Source

pub fn altvals(&self) -> Altvals<'_>

Lazily iterate the altval array as (index, value) pairs, in ascending index order.

Source

pub fn supvals(&self) -> Supvals<'_>

Lazily iterate the supval array as (index, bytes) pairs, in ascending index order.

Source

pub fn hash_entries(&self) -> HashEntries<'_>

Lazily iterate the hash as (key, bytes) pairs, in lexical key order.

Source

pub fn get<T: Persist>(&self, key: &str) -> Option<T>

Read a typed value stored under hash key, or None if the key is absent or its bytes do not decode as T.

The read half of put; see Persist.

Source

pub fn contains(&self, key: &str) -> bool

Whether hash key is set.

Source

pub fn get_serde<T: DeserializeOwned>(&self, key: &str) -> Option<T>

The serde value under hash key, or None if absent or undecodable.

Source

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.

Source

pub fn tag(&mut self, tag: Tag) -> TaggedNetnodeMut<'_>

A read-write view of this node’s arrays under tag, for reaching non-default tags.

Source

pub fn set_altval(&mut self, index: u64, value: u64) -> Result<()>

Set the altval at index.

§Errors

Error::WriteRejected if the kernel rejects the write.

Source

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.

Source

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.

Source

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.

Source

pub fn clear_value(&mut self) -> bool

Delete the node value, returning whether one was set.

Source

pub fn remove_altval(&mut self, index: u64) -> bool

Delete the altval at index, returning whether it was set.

Source

pub fn clear_altvals(&mut self) -> bool

Delete every altval, returning whether any were set.

Source

pub fn remove_supval(&mut self, index: u64) -> bool

Delete the supval byte object at index, returning whether it was set.

Source

pub fn clear_supvals(&mut self) -> bool

Delete every supval byte object, returning whether any were set.

Source

pub fn remove_hash(&mut self, key: &str) -> bool

Delete the hash value for key, returning whether it was set.

Source

pub fn clear_hash(&mut self) -> bool

Delete every hash entry, returning whether any were set.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

pub fn kill(&mut self)

Delete the node and every array attached to it.

The cursor is left pointing at the now-absent id; further reads return None.

Trait Implementations§

Source§

impl Debug for NetnodeMut<'_>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'db> !RefUnwindSafe for NetnodeMut<'db>

§

impl<'db> !Sync for NetnodeMut<'db>

§

impl<'db> !UnwindSafe for NetnodeMut<'db>

§

impl<'db> Freeze for NetnodeMut<'db>

§

impl<'db> Send for NetnodeMut<'db>

§

impl<'db> Unpin for NetnodeMut<'db>

§

impl<'db> UnsafeUnpin for NetnodeMut<'db>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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>,

Source§

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>,

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more