pub trait ServerSideDb:
'static
+ Send
+ Sync
+ Db {
type Connection: Send;
type Transaction<'a>: Send;
type Lock<'a>: Send;
Show 16 methods
// Required methods
fn get_users_who_can_read<'a, 'ret: 'a, T: Object, C: CanDoCallbacks>(
&'ret self,
object_id: ObjectId,
object: &'a T,
cb: &'a C,
) -> Pin<Box<dyn Future<Output = Result<UsersWhoCanRead<Self::Lock<'ret>>>> + 'a>>;
fn get_transaction(
&self,
) -> impl Future<Output = Result<Self::Transaction<'_>>>;
fn get_latest_snapshot(
&self,
transaction: &mut Self::Connection,
user: User,
object_id: ObjectId,
) -> impl Future<Output = Result<Arc<Value>>>;
fn get_all(
&self,
transaction: &mut Self::Connection,
user: User,
object_id: ObjectId,
only_updated_since: Option<Updatedness>,
) -> impl Future<Output = Result<ObjectData>>;
fn server_query(
&self,
user: User,
type_id: TypeId,
only_updated_since: Option<Updatedness>,
query: Arc<Query>,
) -> impl Future<Output = Result<Vec<ObjectId>>>;
fn server_vacuum(
&self,
no_new_changes_before: Option<EventId>,
updatedness: Updatedness,
kill_sessions_older_than: Option<SystemTime>,
notify_recreation: impl FnMut(Update, HashSet<User>),
) -> impl Future<Output = Result<()>>;
fn recreate_at<'a, T: Object, C: CanDoCallbacks>(
&'a self,
object_id: ObjectId,
event_id: EventId,
updatedness: Updatedness,
cb: &'a C,
) -> impl 'a + Future<Output = Result<Option<(EventId, Arc<T>)>>>;
fn create_and_return_rdep_changes<T: Object>(
&self,
object_id: ObjectId,
created_at: EventId,
object: Arc<T>,
updatedness: Updatedness,
) -> impl '_ + Future<Output = Result<Option<(Arc<T>, Vec<ReadPermsChanges>)>>>;
fn submit_and_return_rdep_changes<T: Object>(
&self,
object_id: ObjectId,
event_id: EventId,
event: Arc<T::Event>,
updatedness: Updatedness,
) -> impl '_ + Future<Output = Result<Option<(Arc<T>, Vec<ReadPermsChanges>)>>>;
fn update_pending_rdeps(&self) -> impl '_ + Future<Output = Result<()>>;
fn login_session(
&self,
session: Session,
) -> impl '_ + Future<Output = Result<(SessionToken, SessionRef)>>;
fn resume_session(
&self,
token: SessionToken,
) -> impl '_ + Future<Output = Result<Session>>;
fn mark_session_active(
&self,
token: SessionToken,
at: SystemTime,
) -> impl '_ + Future<Output = Result<()>>;
fn rename_session<'a>(
&'a self,
token: SessionToken,
new_name: &'a str,
) -> impl 'a + Future<Output = Result<()>>;
fn list_sessions(
&self,
user: User,
) -> impl '_ + Future<Output = Result<Vec<Session>>>;
fn disconnect_session(
&self,
user: User,
session: SessionRef,
) -> impl '_ + Future<Output = Result<()>>;
}
Required Associated Types§
Required Methods§
fn get_users_who_can_read<'a, 'ret: 'a, T: Object, C: CanDoCallbacks>( &'ret self, object_id: ObjectId, object: &'a T, cb: &'a C, ) -> Pin<Box<dyn Future<Output = Result<UsersWhoCanRead<Self::Lock<'ret>>>> + 'a>>
fn get_transaction(&self) -> impl Future<Output = Result<Self::Transaction<'_>>>
fn get_latest_snapshot( &self, transaction: &mut Self::Connection, user: User, object_id: ObjectId, ) -> impl Future<Output = Result<Arc<Value>>>
fn get_all( &self, transaction: &mut Self::Connection, user: User, object_id: ObjectId, only_updated_since: Option<Updatedness>, ) -> impl Future<Output = Result<ObjectData>>
fn server_query( &self, user: User, type_id: TypeId, only_updated_since: Option<Updatedness>, query: Arc<Query>, ) -> impl Future<Output = Result<Vec<ObjectId>>>
Sourcefn server_vacuum(
&self,
no_new_changes_before: Option<EventId>,
updatedness: Updatedness,
kill_sessions_older_than: Option<SystemTime>,
notify_recreation: impl FnMut(Update, HashSet<User>),
) -> impl Future<Output = Result<()>>
fn server_vacuum( &self, no_new_changes_before: Option<EventId>, updatedness: Updatedness, kill_sessions_older_than: Option<SystemTime>, notify_recreation: impl FnMut(Update, HashSet<User>), ) -> impl Future<Output = Result<()>>
Cleans up and optimizes up the database
After running this, the database will reject any new change that would happen before
no_new_changes_before
if it is set.
Sourcefn recreate_at<'a, T: Object, C: CanDoCallbacks>(
&'a self,
object_id: ObjectId,
event_id: EventId,
updatedness: Updatedness,
cb: &'a C,
) -> impl 'a + Future<Output = Result<Option<(EventId, Arc<T>)>>>
fn recreate_at<'a, T: Object, C: CanDoCallbacks>( &'a self, object_id: ObjectId, event_id: EventId, updatedness: Updatedness, cb: &'a C, ) -> impl 'a + Future<Output = Result<Option<(EventId, Arc<T>)>>>
This function assumes that the lock on object_id
is already taken
Returns Some
iff the object actually changed
fn create_and_return_rdep_changes<T: Object>( &self, object_id: ObjectId, created_at: EventId, object: Arc<T>, updatedness: Updatedness, ) -> impl '_ + Future<Output = Result<Option<(Arc<T>, Vec<ReadPermsChanges>)>>>
fn submit_and_return_rdep_changes<T: Object>( &self, object_id: ObjectId, event_id: EventId, event: Arc<T::Event>, updatedness: Updatedness, ) -> impl '_ + Future<Output = Result<Option<(Arc<T>, Vec<ReadPermsChanges>)>>>
fn update_pending_rdeps(&self) -> impl '_ + Future<Output = Result<()>>
fn login_session( &self, session: Session, ) -> impl '_ + Future<Output = Result<(SessionToken, SessionRef)>>
fn resume_session( &self, token: SessionToken, ) -> impl '_ + Future<Output = Result<Session>>
fn mark_session_active( &self, token: SessionToken, at: SystemTime, ) -> impl '_ + Future<Output = Result<()>>
fn rename_session<'a>( &'a self, token: SessionToken, new_name: &'a str, ) -> impl 'a + Future<Output = Result<()>>
fn list_sessions( &self, user: User, ) -> impl '_ + Future<Output = Result<Vec<Session>>>
fn disconnect_session( &self, user: User, session: SessionRef, ) -> impl '_ + Future<Output = Result<()>>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.