Struct ClientDb

Source
pub struct ClientDb<LocalDb>
where LocalDb: ClientSideDb,
{ /* private fields */ }

Implementations§

Source§

impl<LocalDb> ClientDb<LocalDb>
where LocalDb: ClientSideDb,

Source

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>
where C: Config, RRL: 'static + Send + Fn(), EH: 'static + Send + Fn(Upload, Error) -> EHF, EHF: 'static + Future<Output = OnError>, VS: 'static + Send + Fn(ClientStorageInfo) -> bool,

Source

pub fn make_ulid(self: &Arc<ClientDb<LocalDb>>) -> Ulid

Source

pub fn listen_for_all_updates( self: &Arc<ClientDb<LocalDb>>, ) -> Receiver<ObjectId>

Source

pub fn listen_for_updates_on( self: &Arc<ClientDb<LocalDb>>, q: QueryId, ) -> Option<Receiver<ObjectId>>

Source

pub fn on_connection_event( self: &Arc<ClientDb<LocalDb>>, cb: impl Send + Sync + Fn(ConnectionEvent) + 'static, )

Source

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.

Source

pub async fn logout(&self) -> Result<(), Error>

Source

pub fn user(&self) -> Option<User>

Source

pub fn watch_upload_queue(&self) -> Receiver<Vec<UploadId>>

Source

pub async fn list_uploads(&self) -> Result<Vec<UploadId>, Error>

Source

pub async fn get_upload( self: &Arc<ClientDb<LocalDb>>, upload_id: UploadId, ) -> Result<Option<Upload>, Error>

Source

pub fn rename_session( self: &Arc<ClientDb<LocalDb>>, name: String, ) -> Receiver<Result<(), Error>>

Source

pub async fn current_session(&self) -> Result<Session, Error>

Source

pub async fn list_sessions(&self) -> Result<Vec<Session>, Error>

Source

pub fn disconnect_session( self: &Arc<ClientDb<LocalDb>>, session_ref: SessionRef, ) -> Receiver<Result<(), Error>>

Source

pub async fn pause_vacuum(&self) -> RwLockReadGuard<'_, ()>

Pauses the vacuum until the returned mutex guard is dropped

Source

pub async fn set_importance<T>( self: &Arc<ClientDb<LocalDb>>, ptr: DbPtr<T>, new_importance: Importance, ) -> Result<(), Error>
where T: Object,

Source

pub fn list_saved_queries( self: &Arc<ClientDb<LocalDb>>, ) -> HashMap<QueryId, SavedQuery>

Source

pub async fn set_query_importance<T>( self: &Arc<ClientDb<LocalDb>>, query_id: QueryId, new_importance: Importance, ) -> Result<(), Error>
where T: Object,

Source

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,

Source

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,

Source

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,

Source

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.

Source

pub async fn get<T>( self: &Arc<ClientDb<LocalDb>>, importance: Importance, ptr: DbPtr<T>, ) -> Result<Obj<T, LocalDb>, Error>
where T: Object,

Source

pub async fn get_local<T>( self: &Arc<ClientDb<LocalDb>>, importance: Importance, ptr: DbPtr<T>, ) -> Result<Option<Obj<T, LocalDb>>, Error>
where T: Object,

Source

pub async fn query_local<'a, T>( self: &'a Arc<ClientDb<LocalDb>>, query: Arc<Query>, ) -> Result<impl Stream + 'a, Error>
where T: Object,

Source

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.

Source

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.

Source

pub async fn get_binary( self: &Arc<ClientDb<LocalDb>>, binary_id: BinPtr, ) -> Result<Option<Arc<[u8]>>, Error>

Trait Implementations§

Source§

impl<LocalDb> Deref for ClientDb<LocalDb>
where LocalDb: ClientSideDb,

Source§

type Target = CacheDb<LocalDb>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<ClientDb<LocalDb> as Deref>::Target

Dereferences the value.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> Send for T
where T: Send,

Source§

impl<T> Sync for T
where T: Sync,