Skip to main content

SqliteStore

Struct SqliteStore 

Source
pub struct SqliteStore { /* private fields */ }

Implementations§

Source§

impl SqliteStore

Source

pub async fn open_default() -> Result<Self, StoreError>

~/.zopp/store.db (creates dir with 0700 perms on unix)

Source

pub async fn open_in_memory() -> Result<Self, StoreError>

Source

pub async fn open(url: &str) -> Result<Self, StoreError>

Trait Implementations§

Source§

impl Store for SqliteStore

Source§

fn create_user<'life0, 'life1, 'async_trait>( &'life0 self, params: &'life1 CreateUserParams, ) -> Pin<Box<dyn Future<Output = Result<(UserId, Option<PrincipalId>), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a new user (returns generated ID, and optional principal ID if principal was provided). If params.principal is provided, atomically creates the user, principal, and adds principal to workspaces.
Source§

fn get_user_by_email<'life0, 'life1, 'async_trait>( &'life0 self, email: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<User, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get user by email.
Source§

fn get_user_by_id<'life0, 'life1, 'async_trait>( &'life0 self, user_id: &'life1 UserId, ) -> Pin<Box<dyn Future<Output = Result<User, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get user by ID.
Source§

fn create_principal<'life0, 'life1, 'async_trait>( &'life0 self, params: &'life1 CreatePrincipalParams, ) -> Pin<Box<dyn Future<Output = Result<PrincipalId, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a new principal (device) for a user.
Source§

fn get_principal<'life0, 'life1, 'async_trait>( &'life0 self, principal_id: &'life1 PrincipalId, ) -> Pin<Box<dyn Future<Output = Result<Principal, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get principal by ID.
Source§

fn rename_principal<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, principal_id: &'life1 PrincipalId, new_name: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Rename a principal.
Source§

fn list_principals<'life0, 'life1, 'async_trait>( &'life0 self, user_id: &'life1 UserId, ) -> Pin<Box<dyn Future<Output = Result<Vec<Principal>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List all principals for a user.
Source§

fn create_invite<'life0, 'life1, 'async_trait>( &'life0 self, params: &'life1 CreateInviteParams, ) -> Pin<Box<dyn Future<Output = Result<Invite, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create an invite token (returns generated ID and token).
Source§

fn get_invite_by_token<'life0, 'life1, 'async_trait>( &'life0 self, token: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Invite, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get invite by token.
Source§

fn list_invites<'life0, 'life1, 'async_trait>( &'life0 self, user_id: Option<&'life1 UserId>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Invite>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List all active invites for a user (None = server invites).
Source§

fn revoke_invite<'life0, 'life1, 'async_trait>( &'life0 self, invite_id: &'life1 InviteId, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Revoke an invite.
Source§

fn create_workspace<'life0, 'life1, 'async_trait>( &'life0 self, params: &'life1 CreateWorkspaceParams, ) -> Pin<Box<dyn Future<Output = Result<WorkspaceId, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a new workspace (returns its generated ID).
Source§

fn list_workspaces<'life0, 'life1, 'async_trait>( &'life0 self, user_id: &'life1 UserId, ) -> Pin<Box<dyn Future<Output = Result<Vec<Workspace>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List all workspaces for a user (via their principals).
Source§

fn get_workspace<'life0, 'life1, 'async_trait>( &'life0 self, ws: &'life1 WorkspaceId, ) -> Pin<Box<dyn Future<Output = Result<Workspace, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get workspace by ID.
Source§

fn get_workspace_by_name<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, user_id: &'life1 UserId, name: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Workspace, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get workspace by name for a user (user must have access).
Source§

fn get_workspace_by_name_for_principal<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, principal_id: &'life1 PrincipalId, name: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Workspace, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get workspace by name for a principal (principal must have access).
Source§

fn add_workspace_principal<'life0, 'life1, 'async_trait>( &'life0 self, params: &'life1 AddWorkspacePrincipalParams, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Add a principal to a workspace with wrapped KEK.
Source§

fn get_workspace_principal<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, workspace_id: &'life1 WorkspaceId, principal_id: &'life2 PrincipalId, ) -> Pin<Box<dyn Future<Output = Result<WorkspacePrincipal, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get workspace principal (to access wrapped KEK).
Source§

fn list_workspace_principals<'life0, 'life1, 'async_trait>( &'life0 self, workspace_id: &'life1 WorkspaceId, ) -> Pin<Box<dyn Future<Output = Result<Vec<WorkspacePrincipal>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List all principals in a workspace (with their wrapped KEKs).
Source§

fn add_user_to_workspace<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, workspace_id: &'life1 WorkspaceId, user_id: &'life2 UserId, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Add a user to a workspace (user-level membership).
Source§

fn create_project<'life0, 'life1, 'async_trait>( &'life0 self, params: &'life1 CreateProjectParams, ) -> Pin<Box<dyn Future<Output = Result<ProjectId, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a project within a workspace (returns generated ID).
Source§

fn list_projects<'life0, 'life1, 'async_trait>( &'life0 self, workspace_id: &'life1 WorkspaceId, ) -> Pin<Box<dyn Future<Output = Result<Vec<Project>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List all projects in a workspace.
Source§

fn get_project<'life0, 'life1, 'async_trait>( &'life0 self, project_id: &'life1 ProjectId, ) -> Pin<Box<dyn Future<Output = Result<Project, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a project by ID.
Source§

fn get_project_by_name<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, workspace_id: &'life1 WorkspaceId, name: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Project, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get a project by name within a workspace.
Source§

fn delete_project<'life0, 'life1, 'async_trait>( &'life0 self, project_id: &'life1 ProjectId, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete a project (and all its environments and secrets).
Source§

fn create_env<'life0, 'life1, 'async_trait>( &'life0 self, params: &'life1 CreateEnvParams, ) -> Pin<Box<dyn Future<Output = Result<EnvironmentId, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create an environment within a project (returns generated ID).
Source§

fn list_environments<'life0, 'life1, 'async_trait>( &'life0 self, project_id: &'life1 ProjectId, ) -> Pin<Box<dyn Future<Output = Result<Vec<Environment>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List all environments in a project.
Source§

fn get_environment<'life0, 'life1, 'async_trait>( &'life0 self, env_id: &'life1 EnvironmentId, ) -> Pin<Box<dyn Future<Output = Result<Environment, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get an environment by ID.
Source§

fn get_environment_by_name<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, project_id: &'life1 ProjectId, name: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Environment, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get an environment by name within a project.
Source§

fn delete_environment<'life0, 'life1, 'async_trait>( &'life0 self, env_id: &'life1 EnvironmentId, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete an environment (and all its secrets).
Source§

fn get_env_wrap<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, ws: &'life1 WorkspaceId, project: &'life2 ProjectName, env: &'life3 EnvName, ) -> Pin<Box<dyn Future<Output = Result<(Vec<u8>, Vec<u8>), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Fetch the (wrapped_dek, dek_nonce) pair for an environment so core can unwrap it (legacy name-based).
Source§

fn upsert_secret<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, env_id: &'life1 EnvironmentId, key: &'life2 str, nonce: &'life3 [u8], ciphertext: &'life4 [u8], ) -> Pin<Box<dyn Future<Output = Result<i64, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Upsert a secret value (AEAD ciphertext + nonce) in an environment. Returns the new environment version after the update.
Source§

fn get_secret<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, env_id: &'life1 EnvironmentId, key: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<SecretRow, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Fetch a secret row (nonce + ciphertext).
Source§

fn list_secret_keys<'life0, 'life1, 'async_trait>( &'life0 self, env_id: &'life1 EnvironmentId, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List all secret keys in an environment.
Source§

fn delete_secret<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, env_id: &'life1 EnvironmentId, key: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<i64, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Delete a secret from an environment. Returns the new environment version after the deletion.

Auto Trait Implementations§

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> ErasedDestructor for T
where T: 'static,

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<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 = !

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

fn try_from(value: U) -> Result<T, !>

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