imessage-database

Crates.ioimessage-database
lib.rsimessage-database
version2.2.1
sourcesrc
created_at2022-12-24 21:37:00.317919
updated_at2024-11-26 19:20:57.38823
descriptionParsers and tools to interact with iMessage SQLite data
homepage
repositoryhttps://github.com/ReagentX/imessage-exporter
max_upload_size
id745069
size2,266,217
Christopher Sardegna (ReagentX)

documentation

README

imessage-database

This library provides interfaces to interact with iMessage Databases.

Installation

This library is available on crates.io.

Documentation

Documentation is available on docs.rs.

Example

use imessage_database::{
    error::table::TableError,
    tables::{
        messages::Message,
        table::{get_connection, Table},
    },
    util::dirs::default_db_path,
};

fn iter_messages() -> Result<(), TableError> {
    /// Create a read-only connection to an iMessage database
    let db = get_connection(&default_db_path()).unwrap();

    /// Create SQL statement
    let mut statement = Message::get(&db)?;

    /// Execute statement
    let messages = statement
        .query_map([], |row| Ok(Message::from_row(row)))
        .unwrap();

    /// Iterate over each row
    for message in messages {
        let mut msg = Message::extract(message)?;

        /// Deserialize message body
        msg.generate_text(&db);

        /// Emit debug info for each message
        println!("{:?}", msg)
    }

    Ok(())
}
Commit count: 1485

cargo fmt