Config

Trait Config 

Source
pub trait Config:
    'static
    + Send
    + Sync
    + Sealed {
    // Required methods
    fn check_ulids();
    fn reencode_old_versions<D: Db>(
        call_on: &D,
    ) -> impl '_ + Future<Output = usize>;
    fn create<D: Db>(
        db: &D,
        type_id: TypeId,
        object_id: ObjectId,
        created_at: EventId,
        snapshot_version: i32,
        object: &Value,
    ) -> impl Future<Output = Result<()>>;
    fn recreate<D: ClientSideDb>(
        db: &D,
        type_id: TypeId,
        object_id: ObjectId,
        created_at: EventId,
        snapshot_version: i32,
        object: &Value,
        updatedness: Option<Updatedness>,
        additional_importance: Importance,
    ) -> impl Future<Output = Result<Option<Value>>>;
    fn submit<D: Db>(
        db: &D,
        type_id: TypeId,
        object_id: ObjectId,
        event_id: EventId,
        event: &Value,
        updatedness: Option<Updatedness>,
        additional_importance: Importance,
    ) -> impl Future<Output = Result<Option<Value>>>;
    fn remove_event<D: ClientSideDb>(
        db: &D,
        type_id: TypeId,
        object_id: ObjectId,
        event_id: EventId,
    ) -> impl Future<Output = Result<()>>;
    fn get_users_who_can_read<'a, D: ServerSideDb, C: CanDoCallbacks>(
        call_on: &'a D,
        object_id: ObjectId,
        type_id: TypeId,
        snapshot_version: i32,
        snapshot: Value,
        cb: &'a C,
    ) -> impl 'a + Future<Output = Result<UsersWhoCanRead<D::Lock<'a>>>>;
    fn recreate_no_lock<'a, D: ServerSideDb, C: CanDoCallbacks>(
        call_on: &'a D,
        type_id: TypeId,
        object_id: ObjectId,
        event_id: EventId,
        updatedness: Updatedness,
        cb: &'a C,
    ) -> impl 'a + Future<Output = Result<Option<(EventId, i32, Value, HashSet<User>)>>>;
    fn upload_object<D: ServerSideDb>(
        call_on: &D,
        user: User,
        updatedness: Updatedness,
        type_id: TypeId,
        object_id: ObjectId,
        created_at: EventId,
        snapshot_version: i32,
        snapshot: Arc<Value>,
    ) -> impl '_ + Future<Output = Result<Option<(Arc<UpdatesWithSnap>, HashSet<User>, Vec<ReadPermsChanges>)>>>;
    fn upload_event<D: ServerSideDb>(
        call_on: &D,
        user: User,
        updatedness: Updatedness,
        type_id: TypeId,
        object_id: ObjectId,
        event_id: EventId,
        event: Arc<Value>,
    ) -> impl '_ + Future<Output = Result<Option<(Arc<UpdatesWithSnap>, Vec<User>, Vec<ReadPermsChanges>)>>>;
}

Required Methods§

Source

fn check_ulids()

Auto-generated by crdb::db!.

Panics if there are two types with the same ULID configured

Source

fn reencode_old_versions<D: Db>(call_on: &D) -> impl '_ + Future<Output = usize>

Source

fn create<D: Db>( db: &D, type_id: TypeId, object_id: ObjectId, created_at: EventId, snapshot_version: i32, object: &Value, ) -> impl Future<Output = Result<()>>

Source

fn recreate<D: ClientSideDb>( db: &D, type_id: TypeId, object_id: ObjectId, created_at: EventId, snapshot_version: i32, object: &Value, updatedness: Option<Updatedness>, additional_importance: Importance, ) -> impl Future<Output = Result<Option<Value>>>

The returned serde_json::Value is guaranteed to be a serialization of the latest snapshot of the object at the current snapshot version

Source

fn submit<D: Db>( db: &D, type_id: TypeId, object_id: ObjectId, event_id: EventId, event: &Value, updatedness: Option<Updatedness>, additional_importance: Importance, ) -> impl Future<Output = Result<Option<Value>>>

The returned serde_json::Value is guaranteed to be a serialization of the latest snapshot of the object at the current snapshot version

Source

fn remove_event<D: ClientSideDb>( db: &D, type_id: TypeId, object_id: ObjectId, event_id: EventId, ) -> impl Future<Output = Result<()>>

Source

fn get_users_who_can_read<'a, D: ServerSideDb, C: CanDoCallbacks>( call_on: &'a D, object_id: ObjectId, type_id: TypeId, snapshot_version: i32, snapshot: Value, cb: &'a C, ) -> impl 'a + Future<Output = Result<UsersWhoCanRead<D::Lock<'a>>>>

Source

fn recreate_no_lock<'a, D: ServerSideDb, C: CanDoCallbacks>( call_on: &'a D, type_id: TypeId, object_id: ObjectId, event_id: EventId, updatedness: Updatedness, cb: &'a C, ) -> impl 'a + Future<Output = Result<Option<(EventId, i32, Value, HashSet<User>)>>>

Source

fn upload_object<D: ServerSideDb>( call_on: &D, user: User, updatedness: Updatedness, type_id: TypeId, object_id: ObjectId, created_at: EventId, snapshot_version: i32, snapshot: Arc<Value>, ) -> impl '_ + Future<Output = Result<Option<(Arc<UpdatesWithSnap>, HashSet<User>, Vec<ReadPermsChanges>)>>>

Source

fn upload_event<D: ServerSideDb>( call_on: &D, user: User, updatedness: Updatedness, type_id: TypeId, object_id: ObjectId, event_id: EventId, event: Arc<Value>, ) -> impl '_ + Future<Output = Result<Option<(Arc<UpdatesWithSnap>, Vec<User>, Vec<ReadPermsChanges>)>>>

The Vec<User> in return type is the list of users who can read the object both before and after the change. Users who gained or lost access to object_id are returned as part of the Vec<ReadPermsChanges>.

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.

Implementors§