pub struct SharedState(/* private fields */);Implementations§
Sourcepub fn get<T: Send + Sync + 'static>(
&self,
key: &str,
) -> Option<Result<Arc<T>, Error>>
pub fn get<T: Send + Sync + 'static>( &self, key: &str, ) -> Option<Result<Arc<T>, Error>>
Returns None if no entry exists for key. Returns Some(Err) if an entry exists for key,
but is not of type T. Returns Some(Ok(Arc
Sourcepub fn try_insert<T: Send + Sync + 'static>(
&self,
key: &str,
val: T,
) -> Result<Arc<T>, Arc<dyn Any + Send + Sync + 'static>>
pub fn try_insert<T: Send + Sync + 'static>( &self, key: &str, val: T, ) -> Result<Arc<T>, Arc<dyn Any + Send + Sync + 'static>>
Insert val at key if key is not yet occupied. If SharedState did not have an entry
for key, returns Ok(Arc<the inserted val>). Otherwise, does not insert val and returns
Err(Arc
Sourcepub async fn get_or_insert_with<F, Fut, T>(
&self,
key: &str,
inserter: F,
) -> Result<Arc<T>, Error>
pub async fn get_or_insert_with<F, Fut, T>( &self, key: &str, inserter: F, ) -> Result<Arc<T>, Error>
This takes two type parameters, F and T. The inserter F is used in case key is not yet
associated with an existing state value to create the value associated with key. T is the
type of state expected to be associated with key. After possibly inserting the state
associated with key in the map, we dynamically cast keys state into type T. Errors can
stem from inserter failures, or existing types in the map not matching T.
Trait Implementations§
Source§fn default() -> SharedState
fn default() -> SharedState
Auto Trait Implementations§
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
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
T to [Self]