pub struct QueryContext {
    pub start: Option<i64>,
    pub end: Option<i64>,
}
Expand description

Represents filter configurations for a SQL query.

Fields§

§start: Option<i64>

The start date filter. Only messages sent on or after this date will be included.

§end: Option<i64>

The end date filter. Only messages sent before this date will be included.

Implementations§

source§

impl QueryContext

source

pub fn set_start(&mut self, start: &str) -> Result<(), QueryContextError>

Generate a QueryContext with a start date

Example:
use imessage_database::util::query_context::QueryContext;

let mut context = QueryContext::default();
context.set_start("2023-01-01");
source

pub fn set_end(&mut self, end: &str) -> Result<(), QueryContextError>

Generate a QueryContext with an end date

Example:
use imessage_database::util::query_context::QueryContext;

let mut context = QueryContext::default();
context.set_end("2023-01-01");
source

pub fn has_filters(&self) -> bool

Determine if the current QueryContext has any filters present

Example:
use imessage_database::util::query_context::QueryContext;

let mut context = QueryContext::default();
assert!(!context.has_filters());
context.set_start("2023-01-01");
assert!(context.has_filters());
source

pub fn generate_filter_statement(&self) -> String

Generate the SQL WHERE clause described by this QueryContext

Example:
use imessage_database::util::query_context::QueryContext;

let mut context = QueryContext::default();
context.set_start("2023-01-01");
let filters = context.generate_filter_statement();

Trait Implementations§

source§

impl Debug for QueryContext

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for QueryContext

source§

fn default() -> QueryContext

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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

§

type Output = T

Should always be Self
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.