Struct Handle

Source
pub struct Handle {
    pub rowid: i32,
    pub id: String,
    pub person_centric_id: Option<String>,
}
Expand description

Represents a single row in the handle table.

Fields§

§rowid: i32

The unique identifier for the handle in the database

§id: String

Identifier for a contact, i.e. a phone number or email address

§person_centric_id: Option<String>

Field used to disambiguate divergent handles that represent the same contact

Trait Implementations§

Source§

impl Cacheable for Handle

Source§

fn cache(db: &Connection) -> Result<HashMap<Self::K, Self::V>, TableError>

Generate a HashMap for looking up contacts by their IDs, collapsing duplicate contacts to the same ID String regardless of service

§Example:
use imessage_database::util::dirs::default_db_path;
use imessage_database::tables::table::{Cacheable, get_connection};
use imessage_database::tables::handle::Handle;

let db_path = default_db_path();
let conn = get_connection(&db_path).unwrap();
let chatrooms = Handle::cache(&conn);
Source§

type K = i32

The key type for the cache HashMap
Source§

type V = String

The value type for the cache HashMap
Source§

impl Debug for Handle

Source§

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

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

impl Deduplicate for Handle

Source§

fn dedupe(duplicated_data: &HashMap<i32, Self::T>) -> HashMap<i32, i32>

Given the initial set of duplicated handles, deduplicate them

This returns a new hashmap that maps the real handle ID to a new deduplicated unique handle ID that represents a single handle for all of the deduplicate handles.

Assuming no new handles have been written to the database, deduplicated data is deterministic across runs.

§Example:
use imessage_database::util::dirs::default_db_path;
use imessage_database::tables::table::{Cacheable, Deduplicate, get_connection};
use imessage_database::tables::handle::Handle;

let db_path = default_db_path();
let conn = get_connection(&db_path).unwrap();
let chatrooms = Handle::cache(&conn).unwrap();
let deduped_chatrooms = Handle::dedupe(&chatrooms);
Source§

type T = String

The type of data being deduplicated
Source§

impl Diagnostic for Handle

Source§

fn run_diagnostic(db: &Connection) -> Result<(), TableError>

Emit diagnostic data for the Handles table

Get the number of handles that are duplicated

The person_centric_id is used to map handles that represent the same contact across ids (numbers, emails, etc) and across services (iMessage, Jabber, iChat, SMS, etc)

In some databases, person_centric_id may not be available.

§Example:
use imessage_database::util::dirs::default_db_path;
use imessage_database::tables::table::{Diagnostic, get_connection};
use imessage_database::tables::handle::Handle;

let db_path = default_db_path();
let conn = get_connection(&db_path).unwrap();
Handle::run_diagnostic(&conn);
Source§

impl Table for Handle

Source§

fn from_row(row: &Row<'_>) -> Result<Handle>

Deserialize a single row into Self, returning a rusqlite::Result
Source§

fn get(db: &Connection) -> Result<CachedStatement<'_>, TableError>

Prepare SELECT * statement
Source§

fn extract( handle: Result<Result<Self, Error>, Error>, ) -> Result<Self, TableError>

Map a rusqlite::Result<Self> into our TableError
Source§

fn stream<F, E>(db: &Connection, callback: F) -> Result<(), TableError>
where F: FnMut(Result<Self, TableError>) -> Result<(), E>,

Process all rows from the table using a callback. This is the most memory-efficient approach for large tables. Read more
Source§

fn get_blob<'a>( &self, db: &'a Connection, table: &str, column: &str, rowid: i64, ) -> Option<Blob<'a>>

Get a BLOB from the table Read more
Source§

fn has_blob( &self, db: &Connection, table: &str, column: &str, rowid: i64, ) -> bool

Check if a BLOB exists in the table

Auto Trait Implementations§

§

impl Freeze for Handle

§

impl RefUnwindSafe for Handle

§

impl Send for Handle

§

impl Sync for Handle

§

impl Unpin for Handle

§

impl UnwindSafe for Handle

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, 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.