pub struct Attribute<T> { /* private fields */ }Expand description
Defines one durable, typed value stored with a Flow.
Declare Attributes on the Flow, add them to crate::PersistenceSchema, and reuse the same
definition from Step and RPC code. Values use Serde serialization. get distinguishes a missing
value with None; get_required converts absence into HandlerError.
§Examples
use dex_sdk::{Attribute, AttributeIndex};
let status = Attribute::<String>::new("status")
.indexed(AttributeIndex::keyword());Implementations§
Source§impl<T> Attribute<T>
impl<T> Attribute<T>
Sourcepub fn indexed(self, index: AttributeIndex) -> Self
pub fn indexed(self, index: AttributeIndex) -> Self
Enables Flow-search indexing with the selected index type.
Sourcepub fn sync_to_attribute_store(self) -> Self
pub fn sync_to_attribute_store(self) -> Self
Enables asynchronous latest-state projection to the Flow’s selected Attribute Store.
The Flow must select a server-configured store with
FlowConfig::attribute_store_names. Deletions
project SQL NULL, and projection failures never roll back the Flow Attribute write.
Sourcepub fn get(&self, context: &Context) -> HandlerResult<Option<T>>where
T: Value,
pub fn get(&self, context: &Context) -> HandlerResult<Option<T>>where
T: Value,
Reads the current value from a Step or RPC invocation.
Returns Ok(None) when no value is stored.
§Errors
Returns HandlerError when the payload cannot be decoded.
Sourcepub fn get_required(&self, context: &Context) -> HandlerResult<T>where
T: Value,
pub fn get_required(&self, context: &Context) -> HandlerResult<T>where
T: Value,
Reads the current value and treats absence as an error.
§Errors
Returns HandlerError when the Attribute is missing or cannot be decoded.
Sourcepub fn set(&self, context: &mut Context, value: T) -> HandlerResult<()>where
T: Value,
pub fn set(&self, context: &mut Context, value: T) -> HandlerResult<()>where
T: Value,
Stages value for durable persistence in the current invocation.
§Errors
Returns HandlerError when the value cannot be encoded or indexed.
Sourcepub fn delete(&self, context: &mut Context) -> HandlerResult<()>
pub fn delete(&self, context: &mut Context) -> HandlerResult<()>
Stages deletion of the current value.
Deleting a missing Attribute is valid.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Attribute<T>
impl<T> RefUnwindSafe for Attribute<T>
impl<T> Send for Attribute<T>
impl<T> Sync for Attribute<T>
impl<T> Unpin for Attribute<T>
impl<T> UnsafeUnpin for Attribute<T>
impl<T> UnwindSafe for Attribute<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request