pub enum Archivable {
Object(Class, Vec<OutputData>),
Data(Vec<OutputData>),
Class(Class),
Placeholder,
Type(Vec<Type>),
}
Expand description
Types of data that can be archived into the typedstream
Variants§
Object(Class, Vec<OutputData>)
An instance of a class that may contain some embedded data. typedstream
data doesn’t include property
names, so data is stored in order of appearance.
Data(Vec<OutputData>)
Some data that is likely a property on the object described by the typedstream
but not part of a class.
Class(Class)
A class referenced in the typedstream
, usually part of an inheritance heirarchy that does not contain any data itself.
Placeholder
A placeholder, only used when reserving a spot in the objects table for a reference to be filled with read class information.
In a typedstream
, the classes are stored in order of inheritance, so the top-level class described by the typedstream
comes before the ones it inherits from. To preserve the order, we reserve the first slot to store the actual object’s data
and then later add it back to the right place.
Type(Vec<Type>)
A type that made it through the parsing process without getting replaced by an object.
Implementations§
Source§impl Archivable
impl Archivable
Sourcepub fn as_nsstring(&self) -> Option<&str>
pub fn as_nsstring(&self) -> Option<&str>
If self
is an Object
that contains a Class
named NSString
or NSMutableString
,
extract a &str
from the associated Data
.
§Example
use imessage_database::util::typedstream::models::{Archivable, Class, OutputData};
let nsstring = Archivable::Object(
Class {
name: "NSString".to_string(),
version: 1
},
vec![OutputData::String("Hello world".to_string())]
);
println!("{:?}", nsstring.as_nsstring()); // Some("Hello world")
let not_nsstring = Archivable::Object(
Class {
name: "NSNumber".to_string(),
version: 1
},
vec![OutputData::SignedInteger(100)]
);
println!("{:?}", not_nsstring.as_nsstring()); // None
Sourcepub fn as_nsnumber_int(&self) -> Option<&i64>
pub fn as_nsnumber_int(&self) -> Option<&i64>
If self
is an Object
that contains a Class
named NSNumber
pointing to a SignedInteger
,
extract an i64
from the Data
.
§Example
use imessage_database::util::typedstream::models::{Archivable, Class, OutputData};
let nsnumber = Archivable::Object(
Class {
name: "NSNumber".to_string(),
version: 1
},
vec![OutputData::SignedInteger(100)]
);
println!("{:?}", nsnumber.as_nsnumber_int()); // Some(100)
let not_nsnumber = Archivable::Object(
Class {
name: "NSString".to_string(),
version: 1
},
vec![OutputData::String("Hello world".to_string())]
);
println!("{:?}", not_nsnumber.as_nsnumber_int()); // None
Sourcepub fn as_nsnumber_float(&self) -> Option<&f64>
pub fn as_nsnumber_float(&self) -> Option<&f64>
If self
is an Object
that contains a Class
named NSNumber
pointing to a Double
,
extract an f64
from the Data
.
§Example
use imessage_database::util::typedstream::models::{Archivable, Class, OutputData};
let nsnumber = Archivable::Object(
Class {
name: "NSNumber".to_string(),
version: 1
},
vec![OutputData::Double(100.001)]
);
println!("{:?}", nsnumber.as_nsnumber_float()); // Some(100.001)
let not_nsnumber = Archivable::Object(
Class {
name: "NSString".to_string(),
version: 1
},
vec![OutputData::String("Hello world".to_string())]
);
println!("{:?}", not_nsnumber.as_nsnumber_float()); // None
Trait Implementations§
Source§impl Clone for Archivable
impl Clone for Archivable
Source§fn clone(&self) -> Archivable
fn clone(&self) -> Archivable
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more