pub struct Attachment {
    pub rowid: i32,
    pub filename: Option<String>,
    pub uti: Option<String>,
    pub mime_type: Option<String>,
    pub transfer_name: Option<String>,
    pub total_bytes: i64,
    pub is_sticker: bool,
    pub hide_attachment: i32,
    pub copied_path: Option<PathBuf>,
}
Expand description

Represents a single row in the attachment table.

Fields§

§rowid: i32§filename: Option<String>§uti: Option<String>§mime_type: Option<String>§transfer_name: Option<String>§total_bytes: i64§is_sticker: bool§hide_attachment: i32§copied_path: Option<PathBuf>

Implementations§

source§

impl Attachment

source

pub fn from_message( db: &Connection, msg: &Message ) -> Result<Vec<Attachment>, TableError>

Gets a Vector of attachments for a single message

source

pub fn mime_type(&self) -> MediaType<'_>

Get the media type of an attachment

source

pub fn as_bytes( &self, platform: &Platform, db_path: &Path, custom_attachment_root: Option<&str> ) -> Result<Option<Vec<u8>>, AttachmentError>

Read the attachment from the disk into a vector of bytes in memory

source

pub fn get_sticker_effect( &self, platform: &Platform, db_path: &Path, custom_attachment_root: Option<&str> ) -> Result<Option<StickerEffect>, AttachmentError>

Determine the StickerEffect of a sticker message

source

pub fn path(&self) -> Option<&Path>

Get the path to an attachment, if it exists

source

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

Get the extension of an attachment, if it exists

source

pub fn filename(&self) -> &str

Get a reasonable filename for an attachment

source

pub fn file_size(&self) -> String

Get a human readable file size for an attachment

source

pub fn resolved_attachment_path( &self, platform: &Platform, db_path: &Path, custom_attachment_root: Option<&str> ) -> Option<String>

Given a platform and database source, resolve the path for the current attachment

For macOS, db_path is unused. For iOS, db_path is the path to the root of the backup directory.

iOS Parsing logic source is from here.

Use the optional custom_attachment_root parameter when the attachments are not stored in the same place as the database expects. The expected location is DEFAULT_ATTACHMENT_ROOT. A custom attachment root like /custom/path will overwrite a path like ~/Library/Messages/Attachments/3d/... to /custom/path/3d...

source

pub fn run_diagnostic( db: &Connection, db_path: &Path, platform: &Platform ) -> Result<(), TableError>

Emit diagnostic data for the Attachments table

This is defined outside of Diagnostic because it requires additional data.

Get the number of attachments that are missing from the filesystem or are missing one of the following columns:

  • ck_server_change_token_blob
  • sr_ck_server_change_token_blob
Example:
use imessage_database::util::{dirs::default_db_path, platform::Platform};
use imessage_database::tables::table::{Diagnostic, get_connection};
use imessage_database::tables::attachment::Attachment;

let db_path = default_db_path();
let conn = get_connection(&db_path).unwrap();
Attachment::run_diagnostic(&conn, &db_path, &Platform::macOS);

Trait Implementations§

source§

impl Debug for Attachment

source§

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

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

impl Table for Attachment

source§

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

Serializes a single row of data to an instance of the struct that implements this Trait
source§

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

Gets a statement we can execute to iterate over the data in the table
source§

fn extract( attachment: Result<Result<Self, Error>, Error> ) -> Result<Self, TableError>

Extract valid row data while handling both types of query errors

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.