pub struct SqliteStore { /* private fields */ }
Expand description
SQLite-based DNS zone and record storage
SqliteStore provides a complete implementation of DNS zone storage using SQLite as the backend database. It supports both in-memory and file-based databases, with optional connection pooling for improved concurrency.
The store handles:
- Zone metadata storage and retrieval
- DNS record persistence with proper indexing
- Transaction-based operations for consistency
- Automatic database schema migrations
- Connection pooling (when enabled)
Implementations§
Source§impl SqliteStore
impl SqliteStore
Sourcepub async fn new(manager: ConnectionManager) -> Result<Self>
pub async fn new(manager: ConnectionManager) -> Result<Self>
Create a new SQLite store with an existing connection manager
Initializes the SQLite store with the provided connection manager and applies any necessary database migrations.
§Arguments
manager
- The connection manager to use for database access
§Returns
A new SqliteStore instance
§Errors
Returns an error if the database cannot be accessed or migrations fail
Sourcepub async fn new_from_config(config: &SqliteConfiguration) -> Result<Self>
pub async fn new_from_config(config: &SqliteConfiguration) -> Result<Self>
Create a new SQLite store from configuration
Creates a new SQLite store using the provided configuration. The configuration determines whether to use a file-based or in-memory database, and whether to enable connection pooling.
§Arguments
config
- The SQLite configuration
§Returns
A new SqliteStore instance
§Errors
Returns an error if the database cannot be created or accessed
Sourcepub async fn new_in_memory() -> Result<Self>
pub async fn new_in_memory() -> Result<Self>
Create a new SQLite store using an in-memory database
Creates a new store that uses an in-memory SQLite database. This is useful for testing or temporary storage where persistence is not required.
§Returns
A new SqliteStore instance with in-memory storage
§Errors
Returns an error if the in-memory database cannot be created
Sourcepub fn journal(&self) -> SqliteJournal
pub fn journal(&self) -> SqliteJournal
Get a journal for recording DNS operations
Returns a journal that can be used to record DNS update operations for this store. The journal uses the same connection manager as the store.
§Returns
A SqliteJournal instance for this store
Source§impl SqliteStore
impl SqliteStore
Sourcepub async fn connection(&self) -> Result<Connection<'_>, CatalogError>
pub async fn connection(&self) -> Result<Connection<'_>, CatalogError>
Get a database connection from the connection manager
Returns a database connection that can be used for direct SQL operations. The connection is automatically managed and will be returned to the pool when dropped (if pooling is enabled).
§Returns
A database connection
§Errors
Returns an error if no connection is available
Sourcepub async fn get(&self, id: ZoneID) -> Result<Zone, CatalogError>
pub async fn get(&self, id: ZoneID) -> Result<Zone, CatalogError>
Get a zone by its unique identifier
Retrieves a complete zone (including all its records) from the database using the zone’s unique ID.
§Arguments
id
- The unique identifier of the zone to retrieve
§Returns
The zone with all its records
§Errors
Returns an error if the zone is not found or cannot be loaded
Sourcepub async fn delete(&self, id: ZoneID) -> Result<(), CatalogError>
pub async fn delete(&self, id: ZoneID) -> Result<(), CatalogError>
Delete a zone and all its records
Removes a zone and all associated records from the database. This operation is permanent and cannot be undone.
§Arguments
id
- The unique identifier of the zone to delete
§Returns
Success if the zone was deleted
§Errors
Returns an error if the zone cannot be deleted
Sourcepub async fn insert(&self, zone: &Zone) -> Result<usize, CatalogError>
pub async fn insert(&self, zone: &Zone) -> Result<usize, CatalogError>
Insert or update a zone and all its records
Stores a zone and all its records in the database. If the zone already exists, it will be updated with the new data.
§Arguments
zone
- The zone to insert or update
§Returns
The number of zones affected (typically 1)
§Errors
Returns an error if the zone cannot be stored
Trait Implementations§
Source§impl CatalogStore<ZoneAuthority<Zone>> for SqliteStore
impl CatalogStore<ZoneAuthority<Zone>> for SqliteStore
Source§fn find<'life0, 'life1, 'async_trait>(
&'life0 self,
origin: &'life1 LowerName,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ZoneAuthority<Zone>>>, CatalogError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find<'life0, 'life1, 'async_trait>(
&'life0 self,
origin: &'life1 LowerName,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ZoneAuthority<Zone>>>, CatalogError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn upsert<'life0, 'life1, 'async_trait>(
&'life0 self,
name: LowerName,
zones: &'life1 [ZoneAuthority<Zone>],
) -> Pin<Box<dyn Future<Output = Result<(), CatalogError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn upsert<'life0, 'life1, 'async_trait>(
&'life0 self,
name: LowerName,
zones: &'life1 [ZoneAuthority<Zone>],
) -> Pin<Box<dyn Future<Output = Result<(), CatalogError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn list<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 LowerName,
) -> Pin<Box<dyn Future<Output = Result<Vec<Name>, CatalogError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 LowerName,
) -> Pin<Box<dyn Future<Output = Result<Vec<Name>, CatalogError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 LowerName,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ZoneAuthority<Zone>>>, CatalogError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 LowerName,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ZoneAuthority<Zone>>>, CatalogError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§impl Clone for SqliteStore
impl Clone for SqliteStore
Source§fn clone(&self) -> SqliteStore
fn clone(&self) -> SqliteStore
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more