pub struct AttributeMapInstance<T> { /* private fields */ }Expand description
Selects one AttributeMap instance for Client::get_attributes.
Since 1.31.0.
Create it with AttributeMap::instance and pass a reference to it in the tuple of reads.
It carries the AttributeMap definition, the instance key, and the value type T.
The read returns Option<T>, which is None when the instance is not set.
It is a different type from AttributeMapLoad.
An AttributeMap::load result selects an instance to load into a handler Context.
Client::get_attributes does not accept it.
Creating an instance selector does not validate the key.
Client::get_attributes rejects an empty key or a key that
contains / with SdkError::InvalidArgument.
§Examples
use dex_sdk::{AttributeMap, Client};
use std::sync::LazyLock;
static LINE_QUANTITIES: LazyLock<AttributeMap<u32>> =
LazyLock::new(|| AttributeMap::new("line-quantities"));
fn read_line_quantity(client: &Client, order_id: &str) -> dex_sdk::SdkResult<u32> {
let (quantity,) = client.get_attributes(order_id, (&LINE_QUANTITIES.instance("line-1"),))?;
Ok(quantity.unwrap_or(0))
}Implementations§
Source§impl<T> AttributeMapInstance<T>
impl<T> AttributeMapInstance<T>
Sourcepub fn attribute_map(&self) -> &AttributeMap<T>
pub fn attribute_map(&self) -> &AttributeMap<T>
Returns the AttributeMap definition this selector reads.
Sourcepub fn instance(&self) -> &str
pub fn instance(&self) -> &str
Returns the instance key exactly as it was passed to AttributeMap::instance.
Trait Implementations§
Source§impl<T: Value> AttributeRead for AttributeMapInstance<T>
impl<T: Value> AttributeRead for AttributeMapInstance<T>
Auto Trait Implementations§
impl<T> Forget for AttributeMapInstance<T>
impl<T> Freeze for AttributeMapInstance<T>where
AttributeMap<T>: Freeze,
impl<T> RefUnwindSafe for AttributeMapInstance<T>where
AttributeMap<T>: RefUnwindSafe,
impl<T> Send for AttributeMapInstance<T>where
AttributeMap<T>: Send,
impl<T> Sync for AttributeMapInstance<T>where
AttributeMap<T>: Sync,
impl<T> Unpin for AttributeMapInstance<T>where
AttributeMap<T>: Unpin,
impl<T> UnsafeUnpin for AttributeMapInstance<T>where
AttributeMap<T>: UnsafeUnpin,
impl<T> UnwindSafe for AttributeMapInstance<T>where
AttributeMap<T>: UnwindSafe,
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