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: i32The unique identifier for the handle in the database
id: StringIdentifier 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
Implementations§
Source§impl Handle
impl Handle
Sourcepub fn dedupe(duplicated_data: &HashMap<i32, String>) -> HashMap<i32, i32>
pub fn dedupe(duplicated_data: &HashMap<i32, String>) -> 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, get_connection};
use imessage_database::tables::handle::Handle;
let db_path = default_db_path();
let conn = get_connection(&db_path).unwrap();
let handles = Handle::cache(&conn).unwrap();
let deduped_handles = Handle::dedupe(&handles);Source§impl Handle
impl Handle
Sourcepub fn run_diagnostic(db: &Connection) -> Result<HandleDiagnostic, TableError>
pub fn run_diagnostic(db: &Connection) -> Result<HandleDiagnostic, TableError>
Compute diagnostic data for the Handles table
Counts 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::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);Trait Implementations§
Source§impl Cacheable for Handle
impl Cacheable for Handle
Source§fn cache(db: &Connection) -> Result<HashMap<Self::K, Self::V>, TableError>
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§impl Table for Handle
impl Table for Handle
Source§fn from_row(row: &Row<'_>) -> Result<Handle>
fn from_row(row: &Row<'_>) -> Result<Handle>
Self. Returns rusqlite::Result
for direct use inside rusqlite::query_map / query_row
callbacks. For high-level iteration, prefer Table::rows or
Table::row.Source§fn get(db: &Connection) -> Result<CachedStatement<'_>, TableError>
fn get(db: &Connection) -> Result<CachedStatement<'_>, TableError>
Source§fn rows<'stmt, P: Params>(
stmt: &'stmt mut Statement<'_>,
params: P,
) -> Result<impl Iterator<Item = Result<Self, TableError>> + 'stmt, TableError>where
Self: 'stmt,
fn rows<'stmt, P: Params>(
stmt: &'stmt mut Statement<'_>,
params: P,
) -> Result<impl Iterator<Item = Result<Self, TableError>> + 'stmt, TableError>where
Self: 'stmt,
stmt, deserializing each via
from_row. Errors at row-fetch or row-deserialize
time are surfaced uniformly as TableError. Accepts both
rusqlite::Statement and rusqlite::CachedStatement (the
latter via deref coercion). Read moreSource§fn row<P: Params>(
stmt: &mut Statement<'_>,
params: P,
) -> Result<Self, TableError>
fn row<P: Params>( stmt: &mut Statement<'_>, params: P, ) -> Result<Self, TableError>
stmt. Returns
TableError::QueryError if the row is missing or fails to
deserialize. Accepts both rusqlite::Statement and
rusqlite::CachedStatement (the latter via deref coercion).Source§fn stream<F, E>(db: &Connection, callback: F) -> Result<(), E>
fn stream<F, E>(db: &Connection, callback: F) -> Result<(), E>
SELECT * query using a
callback. Builds and discards the prepared statement internally, so
the caller never sees it. Read more