pub struct ClientDb<LocalDb>where
LocalDb: ClientSideDb,{ /* private fields */ }
Implementations§
Source§impl<LocalDb> ClientDb<LocalDb>where
LocalDb: ClientSideDb,
impl<LocalDb> ClientDb<LocalDb>where
LocalDb: ClientSideDb,
pub async fn connect<C, RRL, EH, EHF, VS>( config: C, db: LocalDb, cache_watermark: usize, require_relogin: RRL, error_handler: EH, vacuum_schedule: ClientVacuumSchedule<VS>, ) -> Result<(Arc<ClientDb<LocalDb>>, impl Future), Error>
pub fn make_ulid(self: &Arc<ClientDb<LocalDb>>) -> Ulid
pub fn listen_for_all_updates( self: &Arc<ClientDb<LocalDb>>, ) -> Receiver<ObjectId>
pub fn listen_for_updates_on( self: &Arc<ClientDb<LocalDb>>, q: QueryId, ) -> Option<Receiver<ObjectId>>
pub fn on_connection_event( self: &Arc<ClientDb<LocalDb>>, cb: impl Send + Sync + Fn(ConnectionEvent) + 'static, )
Sourcepub async fn login(
self: &Arc<ClientDb<LocalDb>>,
url: Arc<String>,
user: User,
token: SessionToken,
) -> Result<(), Error>
pub async fn login( self: &Arc<ClientDb<LocalDb>>, url: Arc<String>, user: User, token: SessionToken, ) -> Result<(), Error>
Note: The fact that token
is actually a token for the user
passed at creation of this ClientDb
is not actually checked, and is assumed to be true. Providing the wrong user
may lead to object creations
or event submissions being spuriously rejected locally, but will not allow them to succeed remotely anyway.
pub async fn logout(&self) -> Result<(), Error>
pub fn user(&self) -> Option<User>
pub fn watch_upload_queue(&self) -> Receiver<Vec<UploadId>>
pub async fn list_uploads(&self) -> Result<Vec<UploadId>, Error>
pub async fn get_upload( self: &Arc<ClientDb<LocalDb>>, upload_id: UploadId, ) -> Result<Option<Upload>, Error>
pub fn rename_session( self: &Arc<ClientDb<LocalDb>>, name: String, ) -> Receiver<Result<(), Error>>
pub async fn current_session(&self) -> Result<Session, Error>
pub async fn list_sessions(&self) -> Result<Vec<Session>, Error>
pub fn disconnect_session( self: &Arc<ClientDb<LocalDb>>, session_ref: SessionRef, ) -> Receiver<Result<(), Error>>
Sourcepub async fn pause_vacuum(&self) -> RwLockReadGuard<'_, ()>
pub async fn pause_vacuum(&self) -> RwLockReadGuard<'_, ()>
Pauses the vacuum until the returned mutex guard is dropped
pub async fn set_importance<T>(
self: &Arc<ClientDb<LocalDb>>,
ptr: DbPtr<T>,
new_importance: Importance,
) -> Result<(), Error>where
T: Object,
pub fn list_saved_queries( self: &Arc<ClientDb<LocalDb>>, ) -> HashMap<QueryId, SavedQuery>
pub async fn set_query_importance<T>(
self: &Arc<ClientDb<LocalDb>>,
query_id: QueryId,
new_importance: Importance,
) -> Result<(), Error>where
T: Object,
pub async fn create<T>(
self: &Arc<ClientDb<LocalDb>>,
importance: Importance,
object: Arc<T>,
) -> Result<(Obj<T, LocalDb>, impl Future<Output = Result<(), Error>>), Error>where
T: Object,
pub async fn create_with<T>(
self: &Arc<ClientDb<LocalDb>>,
importance: Importance,
object_id: ObjectId,
created_at: EventId,
object: Arc<T>,
) -> Result<impl Future<Output = Result<(), Error>>, Error>where
T: Object,
pub async fn submit<T>(
self: &Arc<ClientDb<LocalDb>>,
ptr: DbPtr<T>,
event: <T as Object>::Event,
) -> Result<impl Future<Output = Result<(), Error>>, Error>where
T: Object,
Sourcepub async fn submit_with<T>(
self: &Arc<ClientDb<LocalDb>>,
importance: Importance,
object_id: ObjectId,
event_id: EventId,
event: Arc<<T as Object>::Event>,
) -> Result<impl Future<Output = Result<(), Error>>, Error>where
T: Object,
pub async fn submit_with<T>(
self: &Arc<ClientDb<LocalDb>>,
importance: Importance,
object_id: ObjectId,
event_id: EventId,
event: Arc<<T as Object>::Event>,
) -> Result<impl Future<Output = Result<(), Error>>, Error>where
T: Object,
Note: this will fail if the object is not subscribed upon yet: it would not make sense anyway.
pub async fn get<T>(
self: &Arc<ClientDb<LocalDb>>,
importance: Importance,
ptr: DbPtr<T>,
) -> Result<Obj<T, LocalDb>, Error>where
T: Object,
pub async fn get_local<T>(
self: &Arc<ClientDb<LocalDb>>,
importance: Importance,
ptr: DbPtr<T>,
) -> Result<Option<Obj<T, LocalDb>>, Error>where
T: Object,
pub async fn query_local<'a, T>(
self: &'a Arc<ClientDb<LocalDb>>,
query: Arc<Query>,
) -> Result<impl Stream + 'a, Error>where
T: Object,
Sourcepub async fn query_remote<'a, T>(
self: &'a Arc<ClientDb<LocalDb>>,
importance: Importance,
query_id: QueryId,
query: Arc<Query>,
) -> Result<impl Stream + 'a, Error>where
T: Object,
pub async fn query_remote<'a, T>(
self: &'a Arc<ClientDb<LocalDb>>,
importance: Importance,
query_id: QueryId,
query: Arc<Query>,
) -> Result<impl Stream + 'a, Error>where
T: Object,
Note that it is assumed here that the same QueryId will always be associated with the same Query. In particular, this means that when bumping an Object’s snapshot_version and adjusting the queries accordingly, you should change the QueryId, as well as unsubscribe/resubscribe on startup so that the database gets updated.
Sourcepub async fn create_binary(
self: &Arc<ClientDb<LocalDb>>,
data: Arc<[u8]>,
) -> Result<(), Error>
pub async fn create_binary( self: &Arc<ClientDb<LocalDb>>, data: Arc<[u8]>, ) -> Result<(), Error>
Note: when creating a binary, it can be vacuumed away at any time until an object or
event is added that requires it. As such, you probably want to use pause_vacuum
to make sure the created binary is not vacuumed away before the object or event
had enough time to get created.
pub async fn get_binary( self: &Arc<ClientDb<LocalDb>>, binary_id: BinPtr, ) -> Result<Option<Arc<[u8]>>, Error>
Trait Implementations§
Auto Trait Implementations§
impl<LocalDb> !Freeze for ClientDb<LocalDb>
impl<LocalDb> !RefUnwindSafe for ClientDb<LocalDb>
impl<LocalDb> Send for ClientDb<LocalDb>
impl<LocalDb> Sync for ClientDb<LocalDb>
impl<LocalDb> Unpin for ClientDb<LocalDb>
impl<LocalDb> !UnwindSafe for ClientDb<LocalDb>
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> 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> ⓘ
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> ⓘ
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