ChatToHandle

Struct ChatToHandle 

Source
pub struct ChatToHandle { /* private fields */ }
Expand description

Represents a single row in the chat_handle_join table.

Implementations§

Source§

impl ChatToHandle

Source

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::{Diagnostic, 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);
Source

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

Source§

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

Generate a hashmap containing each chatroom’s ID pointing to a HashSet 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§

type K = i32

The key type for the cache HashMap
Source§

type V = BTreeSet<i32>

The value type for the cache HashMap
Source§

impl Diagnostic for ChatToHandle

Source§

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

Emit 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::{Diagnostic, 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 Table for ChatToHandle

Source§

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

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

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

Prepare SELECT * statement
Source§

fn extract( chat_to_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§

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.