Skip to main content

Chat

Struct Chat 

Source
pub struct Chat {
    pub rowid: i32,
    pub chat_identifier: String,
    pub service_name: Option<String>,
    pub display_name: Option<String>,
}
Expand description

Row from the chat table.

Fields§

§rowid: i32

Chat row ID.

§chat_identifier: String

Phone number, email, or group chat identifier.

§service_name: Option<String>

Service name stored for the chat.

§display_name: Option<String>

User-provided chat display name.

Implementations§

Source§

impl Chat

Source

pub fn name(&self) -> &str

Return the display name, falling back to the chat identifier.

Source

pub fn display_name(&self) -> Option<&str>

Return the non-empty custom display name.

Source

pub fn service(&self) -> Service<'_>

Return the chat service as a Service.

Source

pub fn properties(&self, db: &Connection) -> Option<Properties>

Parse Properties from the chat’s plist blob.

Calling this reads a BLOB from the database.

Trait Implementations§

Source§

impl Cacheable for Chat

Source§

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

Cache chat rows by row ID.

Chat row IDs can represent duplicate conversations; deduplication happens after participant handles are loaded.

§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§

type K = i32

Key type for the cache map.
Source§

type V = Chat

Value type for the cache map.
Source§

impl Debug for Chat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Table for Chat

Source§

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

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>

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,

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 more
Source§

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>
where E: From<TableError>, F: FnMut(Result<Self, TableError>) -> 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 more
Source§

fn get_blob<'a>( &self, db: &'a Connection, table: &str, column: &str, rowid: i64, ) -> Option<Blob<'a>>

Open a BLOB column for the supplied rowid.
Source§

fn has_blob( &self, db: &Connection, table: &str, column: &str, rowid: i64, ) -> bool

Return whether a BLOB column is non-null for the supplied rowid.

Auto Trait Implementations§

§

impl Freeze for Chat

§

impl RefUnwindSafe for Chat

§

impl Send for Chat

§

impl Sync for Chat

§

impl Unpin for Chat

§

impl UnsafeUnpin for Chat

§

impl UnwindSafe for Chat

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.