Struct SqliteStore

Source
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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

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,

Find zones by origin name Read more
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,

Insert or update zones for a given name Read more
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,

List all zone names in the catalog Read more
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,

Remove a zone from the catalog Read more
Source§

impl Clone for SqliteStore

Source§

fn clone(&self) -> SqliteStore

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SqliteStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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
Source§

impl<T> ErasedDestructor for T
where T: 'static,