Skip to main content

DelegateCtx

Struct DelegateCtx 

Source
pub struct DelegateCtx { /* private fields */ }
Expand description

Opaque handle to the delegate’s execution environment.

Provides access to both:

  • Temporary context: State shared within a single message batch (reset between calls)
  • Persistent secrets: Encrypted storage that survives across all invocations

§Context Methods

§Secret Methods

Implementations§

Source§

impl DelegateCtx

Source

pub fn len(&self) -> usize

Returns the current context length in bytes.

Source

pub fn is_empty(&self) -> bool

Returns true if the context is empty.

Source

pub fn read(&self) -> Vec<u8>

Read the current context bytes.

Returns an empty Vec if no context has been written.

Source

pub fn read_into(&self, buf: &mut [u8]) -> usize

Read context into a provided buffer.

Returns the number of bytes actually read.

Source

pub fn write(&mut self, data: &[u8]) -> bool

Write new context bytes, replacing any existing content.

Returns true on success, false on error.

Source

pub fn clear(&mut self)

Clear the context.

Source

pub fn get_secret_len(&self, key: &[u8]) -> Option<usize>

Get the length of a secret without retrieving its value.

Returns None if the secret does not exist.

Source

pub fn get_secret(&self, key: &[u8]) -> Option<Vec<u8>>

Get a secret by key.

Returns None if the secret does not exist.

Source

pub fn set_secret(&mut self, key: &[u8], value: &[u8]) -> bool

Store a secret.

Returns true on success, false on error.

Source

pub fn has_secret(&self, key: &[u8]) -> bool

Check if a secret exists.

Source

pub fn remove_secret(&mut self, key: &[u8]) -> bool

Remove a secret.

Returns true if the secret was removed, false if it didn’t exist.

Trait Implementations§

Source§

impl Debug for DelegateCtx

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for DelegateCtx

Source§

fn default() -> DelegateCtx

Returns the “default value” for a type. Read more

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

Source§

type Output = T

Should always be Self
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