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

Represents a single row in the chat table.

Fields§

§rowid: i32

The unique identifier for the chat in the database

§chat_identifier: String

The 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 created for the chat

Implementations§

Source§

impl Chat

Source

pub fn name(&self) -> &str

Generate a name for a chat, falling back to the default if a custom one is not set

Source

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

Get the current display name for the chat, if it exists.

Source

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

Get the service used by the chat, i.e. iMessage, SMS, IRC, etc.

Source

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

Source§

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§

type K = i32

The key type for the cache HashMap
Source§

type V = Chat

The value type for the cache HashMap
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, returning a rusqlite::Result
Source§

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

Prepare SELECT * statement
Source§

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

§

impl Freeze for Chat

§

impl RefUnwindSafe for Chat

§

impl Send for Chat

§

impl Sync for Chat

§

impl Unpin 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.