pub struct Context(/* private fields */);Expand description
Context is used to provide a local interface to fetch and subscribe to entities with a specific ContextData. Generally this means your auth token for a specific user, but ContextData is abstracted so you can use what you want.
Implementations§
Source§impl Context
impl Context
pub fn new<SE: StorageEngine + Send + Sync + 'static, PA: PolicyAgent + Send + Sync + 'static>( node: Node<SE, PA>, data: PA::ContextData, ) -> Self
pub fn node_id(&self) -> EntityId
pub async fn get<R: View>(&self, id: EntityId) -> Result<R, RetrievalError>
Sourcepub async fn get_cached<R: View>(
&self,
id: EntityId,
) -> Result<R, RetrievalError>
pub async fn get_cached<R: View>( &self, id: EntityId, ) -> Result<R, RetrievalError>
Get an entity, but its ok to return early if the entity is already in the local node storage
pub async fn fetch<R: View>( &self, args: impl TryInto<MatchArgs, Error = impl Into<RetrievalError>>, ) -> Result<Vec<R>, RetrievalError>
pub async fn fetch_one<R: View + Clone + 'static>( &self, args: impl TryInto<MatchArgs, Error = impl Into<RetrievalError>>, ) -> Result<Option<R>, RetrievalError>
Sourcepub fn query<R>(
&self,
args: impl TryInto<MatchArgs, Error = impl Into<RetrievalError>>,
) -> Result<LiveQuery<R>, RetrievalError>where
R: View,
pub fn query<R>(
&self,
args: impl TryInto<MatchArgs, Error = impl Into<RetrievalError>>,
) -> Result<LiveQuery<R>, RetrievalError>where
R: View,
Subscribe to changes in entities matching a selection
Sourcepub async fn query_wait<R>(
&self,
args: impl TryInto<MatchArgs, Error = impl Into<RetrievalError>>,
) -> Result<LiveQuery<R>, RetrievalError>where
R: View,
pub async fn query_wait<R>(
&self,
args: impl TryInto<MatchArgs, Error = impl Into<RetrievalError>>,
) -> Result<LiveQuery<R>, RetrievalError>where
R: View,
Subscribe to changes in entities matching a selection and wait for initialization
pub async fn collection( &self, id: &CollectionId, ) -> Result<StorageCollectionWrapper, RetrievalError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Context
impl !RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl !UnwindSafe for Context
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
Mutably borrows from an owned value. Read more
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more