Skip to main content

StateCallbacks

Struct StateCallbacks 

Source
#[repr(C)]
pub struct StateCallbacks { pub get: extern "C" fn(operator_id: u64, ctx: *mut FFIContext, key: *const u8, key_len: usize, output: *mut BufferFFI) -> i32, pub set: extern "C" fn(operator_id: u64, ctx: *mut FFIContext, key: *const u8, key_len: usize, value: *const u8, value_len: usize) -> i32, pub remove: extern "C" fn(operator_id: u64, ctx: *mut FFIContext, key: *const u8, key_len: usize) -> i32, pub clear: extern "C" fn(operator_id: u64, ctx: *mut FFIContext) -> i32, pub prefix: extern "C" fn(operator_id: u64, ctx: *mut FFIContext, prefix: *const u8, prefix_len: usize, iterator_out: *mut *mut StateIteratorFFI) -> i32, pub iterator_next: extern "C" fn(iterator: *mut StateIteratorFFI, key_out: *mut BufferFFI, value_out: *mut BufferFFI) -> i32, pub iterator_free: extern "C" fn(iterator: *mut StateIteratorFFI), }
Expand description

State management callbacks

Fields§

§get: extern "C" fn(operator_id: u64, ctx: *mut FFIContext, key: *const u8, key_len: usize, output: *mut BufferFFI) -> i32

Get a value from operator state

§Parameters

  • operator_id: Operator ID
  • ctx: FFI context
  • key: Key bytes
  • key_len: Length of key
  • output: Buffer to receive value

§Returns

  • 0 if value exists and retrieved, 1 if key not found, negative on error
§set: extern "C" fn(operator_id: u64, ctx: *mut FFIContext, key: *const u8, key_len: usize, value: *const u8, value_len: usize) -> i32

Set a value in operator state

§Parameters

  • operator_id: Operator ID
  • ctx: FFI context
  • key: Key bytes
  • key_len: Length of key
  • value: Value bytes
  • value_len: Length of value

§Returns

  • 0 on success, negative error code on failure
§remove: extern "C" fn(operator_id: u64, ctx: *mut FFIContext, key: *const u8, key_len: usize) -> i32

Remove a value from operator state

§Parameters

  • operator_id: Operator ID
  • ctx: FFI context
  • key: Key bytes
  • key_len: Length of key

§Returns

  • 0 on success, negative error code on failure
§clear: extern "C" fn(operator_id: u64, ctx: *mut FFIContext) -> i32

Clear all state for an operator

§Parameters

  • operator_id: Operator ID
  • ctx: FFI context

§Returns

  • 0 on success, negative error code on failure
§prefix: extern "C" fn(operator_id: u64, ctx: *mut FFIContext, prefix: *const u8, prefix_len: usize, iterator_out: *mut *mut StateIteratorFFI) -> i32

Create an iterator for state keys with a given prefix

§Parameters

  • operator_id: Operator ID
  • ctx: FFI context
  • prefix: Prefix bytes
  • prefix_len: Length of prefix
  • iterator_out: Pointer to receive iterator handle

§Returns

  • 0 on success, negative error code on failure
§iterator_next: extern "C" fn(iterator: *mut StateIteratorFFI, key_out: *mut BufferFFI, value_out: *mut BufferFFI) -> i32

Get the next key-value pair from a state iterator

§Parameters

  • iterator: Iterator handle
  • key_out: Buffer to receive key
  • value_out: Buffer to receive value

§Returns

  • 0 on success, 1 if end of iteration, negative on error
§iterator_free: extern "C" fn(iterator: *mut StateIteratorFFI)

Free a state iterator

§Parameters

  • iterator: Iterator to free

Trait Implementations§

Source§

impl Clone for StateCallbacks

Source§

fn clone(&self) -> StateCallbacks

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for StateCallbacks

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.