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

impl PartialEq for QueryContext

source§

fn eq(&self, other: &QueryContext) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for QueryContext

source§

impl StructuralEq for QueryContext

source§

impl StructuralPartialEq for QueryContext

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.