pub struct Chat {
pub rowid: i32,
pub chat_identifier: String,
pub service_name: Option<String>,
pub display_name: Option<String>,
}Expand description
Represents a single row in the chat table.
Fields§
§rowid: i32The unique identifier for the chat in the database
chat_identifier: StringThe identifier for the chat, typically a phone number, email, or group chat ID
service_name: Option<String>The service the chat used, i.e. iMessage, SMS, IRC, etc.
display_name: Option<String>Optional custom name created for the chat
Implementations§
Source§impl Chat
impl Chat
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Generate a name for a chat, falling back to the default if a custom one is not set
Sourcepub fn display_name(&self) -> Option<&str>
pub fn display_name(&self) -> Option<&str>
Get the current display name for the chat, if it exists.
Sourcepub fn service(&self) -> Service<'_>
pub fn service(&self) -> Service<'_>
Get the service used by the chat, i.e. iMessage, SMS, IRC, etc.
Sourcepub fn properties(&self, db: &Connection) -> Option<Properties>
pub fn properties(&self, db: &Connection) -> Option<Properties>
Get the Properties for the chat, if they exist
Calling this hits the database, so it is expensive and should only get invoked when needed.
Trait Implementations§
Source§impl Cacheable for Chat
impl Cacheable for Chat
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 the chatroom’s metadata.
These chatroom ID’s contain duplicates and must be deduped later once we have all of the participants parsed out. On its own this data is not useful.
§Example:
use imessage_database::util::dirs::default_db_path;
use imessage_database::tables::table::{Cacheable, get_connection};
use imessage_database::tables::chat::Chat;
let db_path = default_db_path();
let conn = get_connection(&db_path).unwrap();
let chatrooms = Chat::cache(&conn);Source§impl Table for Chat
impl Table for Chat
Source§fn from_row(row: &Row<'_>) -> Result<Chat>
fn from_row(row: &Row<'_>) -> Result<Chat>
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