Skip to main content

Crate webgates_repositories

Crate webgates_repositories 

Source
Expand description

§webgates-repositories

Repository traits, in-memory implementations, and storage backends for webgates applications.

This crate is the persistence layer of the workspace. It provides repository traits, in-memory implementations, optional database backends, shared repository errors, and repository-scoped workflows for common account operations.

§When to use this crate

Use webgates-repositories when you want:

  • persistence contracts for accounts, secrets, groups, and permission mappings
  • in-memory repositories for tests or local development
  • SeaORM or SurrealDB storage backends
  • session repository implementations for webgates-sessions
  • repository-level services such as account insert and delete

§Key modules

Most developers should choose one layer first:

  • start with account_repository, secret_repository, or the other trait modules when defining a persistence boundary
  • start with memory when you want zero-configuration repositories for tests or local development
  • move to services when you want repository-scoped account workflows
  • enable surrealdb or sea_orm only when you are ready to connect a real backend

Use these canonical module paths instead of crate-root shortcuts.

§Examples

In-memory repositories are the easiest way to get started:

use std::sync::Arc;
use webgates_core::groups::Group;
use webgates_core::roles::Role;
use webgates_repositories::memory::account::MemoryAccountRepository;
use webgates_repositories::memory::secret::MemorySecretRepository;

let accounts = Arc::new(MemoryAccountRepository::<Role, Group>::default());
let secrets = Arc::new(MemorySecretRepository::new_with_argon2_hasher().unwrap());

let _ = (accounts, secrets);

§Getting started on docs.rs

A good reading order is:

  1. account_repository and secret_repository
  2. memory
  3. services
  4. sea_orm or surrealdb if you need persistent storage

Modules§

account_repository
Account repository traits and contracts.
audit
Audit logging utilities for repository-scoped account workflows.
comma_separated_value
Comma-separated value conversion trait for SeaORM storage.
errors
Error types and result aliases for repository implementations.
group_repository
Group repository traits and contracts.
memory
In-memory repository implementations for development and testing.
permission_mapping_repository
Permission-mapping repository traits and contracts.
sea_orm
SeaORM repository integration.
secret_repository
Secret repository traits and contracts.
services
Repository-level services for common account workflows.
surrealdb
SurrealDB-backed repositories.

Enums§

TableName
Canonical table or collection names shared by storage backends.