pub struct ChatToHandle { /* private fields */ }Expand description
Represents a single row in the chat_handle_join table.
Implementations§
Source§impl ChatToHandle
impl ChatToHandle
Sourcepub fn run_diagnostic(
db: &Connection,
) -> Result<ChatHandleDiagnostic, TableError>
pub fn run_diagnostic( db: &Connection, ) -> Result<ChatHandleDiagnostic, TableError>
Compute diagnostic data for the Chat to Handle join table
Get the number of chats referenced in the messages table that do not exist in this join table:
§Example:
use imessage_database::util::dirs::default_db_path;
use imessage_database::tables::table::get_connection;
use imessage_database::tables::chat_handle::ChatToHandle;
let db_path = default_db_path();
let conn = get_connection(&db_path).unwrap();
ChatToHandle::run_diagnostic(&conn);Source§impl ChatToHandle
impl ChatToHandle
Sourcepub fn get_chat_lookup_map(
conn: &Connection,
) -> Result<HashMap<i32, i32>, TableError>
pub fn get_chat_lookup_map( conn: &Connection, ) -> Result<HashMap<i32, i32>, TableError>
Get the chat lookup map from the database, if it exists
This is used to map chat IDs that are split across services to a canonical chat ID for deduplication purposes.
§Example:
use imessage_database::util::dirs::default_db_path;
use imessage_database::tables::table::get_connection;
use imessage_database::tables::chat_handle::ChatToHandle;
let db_path = default_db_path();
let conn = get_connection(&db_path).unwrap();
ChatToHandle::get_chat_lookup_map(&conn);Sourcepub fn dedupe(
duplicated_data: &HashMap<i32, BTreeSet<i32>>,
chat_lookup_map: &HashMap<i32, i32>,
) -> Result<HashMap<i32, i32>, TableError>
pub fn dedupe( duplicated_data: &HashMap<i32, BTreeSet<i32>>, chat_lookup_map: &HashMap<i32, i32>, ) -> Result<HashMap<i32, i32>, TableError>
Given the initial set of duplicated chats, deduplicate them based on the participants
This returns a new hashmap that maps the real chat ID to a new deduplicated unique chat ID that represents a single chat for all of the same participants, even if they have multiple handles.
Assuming no new chat-handle relationships have been written to the database, deduplicated data is deterministic across runs.
§Example:
use std::collections::HashMap;
use imessage_database::util::dirs::default_db_path;
use imessage_database::tables::table::{Cacheable, get_connection};
use imessage_database::tables::chat_handle::ChatToHandle;
let db_path = default_db_path();
let conn = get_connection(&db_path).unwrap();
let chatrooms = ChatToHandle::cache(&conn).unwrap();
let deduped_chatrooms = ChatToHandle::dedupe(&chatrooms, &HashMap::new());Trait Implementations§
Source§impl Cacheable for ChatToHandle
impl Cacheable for ChatToHandle
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 containing each chatroom’s ID pointing to a BTreeSet of participant handle IDs
§Example:
use imessage_database::util::dirs::default_db_path;
use imessage_database::tables::table::{Cacheable, get_connection};
use imessage_database::tables::chat_handle::ChatToHandle;
let db_path = default_db_path();
let conn = get_connection(&db_path).unwrap();
let chatrooms = ChatToHandle::cache(&conn);Source§impl Debug for ChatToHandle
impl Debug for ChatToHandle
Source§impl Table for ChatToHandle
impl Table for ChatToHandle
Source§fn from_row(row: &Row<'_>) -> Result<ChatToHandle>
fn from_row(row: &Row<'_>) -> Result<ChatToHandle>
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