Skip to main content

Database

Struct Database 

Source
pub struct Database { /* private fields */ }
Expand description

Database connection pool and operations.

Implementations§

Source§

impl Database

Source

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>

Open a database at the given path.

Source

pub fn with_config(config: DatabaseConfig) -> Result<Self>

Open a database with the given configuration.

Source

pub fn conn(&self) -> Result<PooledConnection<SqliteConnectionManager>>

Get a connection from the pool.

Source

pub fn initialize(&self) -> Result<()>

Initialize the database schema.

Source

pub fn is_initialized(&self) -> Result<bool>

Check if the database is initialized.

Source

pub fn migrate_if_needed(&self) -> Result<()>

Migrate the database schema if needed.

Call this on an existing database to upgrade it to the current schema version.

Source

pub fn begin_transaction(&self) -> Result<Transaction>

Begin a transaction for bulk operations.

Source

pub fn insert_record(&self, record: &UlsRecord) -> Result<()>

Insert a ULS record into the database.

Source

pub fn get_license_by_callsign(&self, callsign: &str) -> Result<Option<License>>

Look up a license by call sign.

Source

pub fn get_licenses_by_frn(&self, frn: &str) -> Result<Vec<License>>

Look up all licenses by FRN (FCC Registration Number).

Source

pub fn get_stats(&self) -> Result<LicenseStats>

Get database statistics.

Source

pub fn count_by_service(&self, service_codes: &[&str]) -> Result<u64>

Count licenses by radio service code(s). Pass service codes like [“HA”, “HV”] for amateur or [“ZA”] for GMRS.

Source

pub fn set_last_updated(&self, timestamp: &str) -> Result<()>

Set the last updated timestamp.

Source

pub fn get_imported_etag(&self, service: &str) -> Result<Option<String>>

Get the ETag of the last imported file for a service.

Source

pub fn set_imported_etag(&self, service: &str, etag: &str) -> Result<()>

Set the ETag of the last imported file for a service.

Source

pub fn has_record_type(&self, service: &str, record_type: &str) -> Result<bool>

Check if a record type has been imported for a service.

Source

pub fn get_imported_types(&self, service: &str) -> Result<Vec<String>>

Get list of imported record types for a service.

Source

pub fn mark_imported( &self, service: &str, record_type: &str, count: usize, ) -> Result<()>

Mark record type as imported for a service.

Source

pub fn clear_import_status(&self, service: &str) -> Result<()>

Clear import status for a service (used when doing full re-import).

Source

pub fn get_imported_count( &self, service: &str, record_type: &str, ) -> Result<Option<usize>>

Get record count for an imported record type.

Source

pub fn get_last_updated(&self) -> Result<Option<String>>

Get the last updated timestamp for a service.

Source

pub fn get_freshness( &self, service: &str, threshold_days: i64, ) -> Result<DataFreshness>

Get data freshness information for a service.

Source

pub fn is_stale(&self, service: &str, threshold_days: i64) -> Result<bool>

Check if data for a service is stale.

Source

pub fn record_applied_patch( &self, service: &str, patch_date: NaiveDate, weekday: &str, etag: Option<&str>, record_count: Option<usize>, ) -> Result<()>

Record that a daily patch has been applied.

Source

pub fn get_applied_patches(&self, service: &str) -> Result<Vec<AppliedPatch>>

Get all applied patches for a service since last weekly.

Source

pub fn clear_applied_patches(&self, service: &str) -> Result<()>

Clear applied patches for a service (called when new weekly is imported).

Source

pub fn set_last_weekly_date(&self, service: &str, date: NaiveDate) -> Result<()>

Set the date of the last weekly import for a service.

Source

pub fn get_last_weekly_date(&self, service: &str) -> Result<Option<NaiveDate>>

Get the date of the last weekly import for a service.

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