pub struct ChatToHandle { /* private fields */ }Expand description
Row from 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_handle_join table.
Counts chats referenced by messages but missing from 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>
Load the chat_lookup canonical chat map when the table exists.
The map links chat IDs split across services to a canonical chat ID for deduplication.
§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>
Assign stable deduplicated IDs to chats.
Chats merge when they have the same participant set or are linked by
chat_lookup.
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>
Cache participant handle IDs by chat row ID.
§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>
Deserialize a single row into
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>
Prepare the table’s default
SELECT * statement.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,
Iterate over rows produced by
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>
Fetch exactly one row from
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>
Process every row from the table’s default
SELECT * query using a
callback. Builds and discards the prepared statement internally, so
the caller never sees it. Read moreAuto Trait Implementations§
impl Freeze for ChatToHandle
impl RefUnwindSafe for ChatToHandle
impl Send for ChatToHandle
impl Sync for ChatToHandle
impl Unpin for ChatToHandle
impl UnsafeUnpin for ChatToHandle
impl UnwindSafe for ChatToHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more