Struct binaryninja::typearchive::TypeArchive
source · pub struct TypeArchive { /* private fields */ }
Expand description
Type Archives are a collection of types which can be shared between different analysis sessions and are backed by a database file on disk. Their types can be modified, and a history of previous versions of types is stored in snapshots in the archive.
Implementations§
source§impl TypeArchive
impl TypeArchive
sourcepub fn open<S: BnStrCompatible>(path: S) -> Option<TypeArchive>
pub fn open<S: BnStrCompatible>(path: S) -> Option<TypeArchive>
Open the Type Archive at the given path, if it exists.
sourcepub fn create<S: BnStrCompatible>(
path: S,
platform: &Platform
) -> Option<TypeArchive>
pub fn create<S: BnStrCompatible>( path: S, platform: &Platform ) -> Option<TypeArchive>
Create a Type Archive at the given path, returning None if it could not be created.
sourcepub fn create_with_id<P: BnStrCompatible, I: BnStrCompatible>(
path: P,
id: I,
platform: &Platform
) -> Option<TypeArchive>
pub fn create_with_id<P: BnStrCompatible, I: BnStrCompatible>( path: P, id: I, platform: &Platform ) -> Option<TypeArchive>
Create a Type Archive at the given path and id, returning None if it could not be created.
sourcepub fn lookup_by_id<S: BnStrCompatible>(id: S) -> Option<TypeArchive>
pub fn lookup_by_id<S: BnStrCompatible>(id: S) -> Option<TypeArchive>
Get a reference to the Type Archive with the known id, if one exists.
sourcepub fn current_snapshot_id(&self) -> BnString
pub fn current_snapshot_id(&self) -> BnString
Get the id of the current snapshot in the type archive
sourcepub fn set_current_snapshot_id<S: BnStrCompatible>(&self, id: S)
pub fn set_current_snapshot_id<S: BnStrCompatible>(&self, id: S)
Revert the type archive’s current snapshot to the given snapshot
sourcepub fn all_snapshot_ids(&self) -> Array<BnString>
pub fn all_snapshot_ids(&self) -> Array<BnString>
Get a list of every snapshot’s id
sourcepub fn get_snapshot_parent_ids<S: BnStrCompatible>(
&self,
snapshot: S
) -> Option<Array<BnString>>
pub fn get_snapshot_parent_ids<S: BnStrCompatible>( &self, snapshot: S ) -> Option<Array<BnString>>
Get the ids of the parents to the given snapshot
sourcepub fn get_snapshot_child_ids<S: BnStrCompatible>(
&self,
snapshot: S
) -> Option<Array<BnString>>
pub fn get_snapshot_child_ids<S: BnStrCompatible>( &self, snapshot: S ) -> Option<Array<BnString>>
Get the ids of the children to the given snapshot
sourcepub fn add_type(&self, name: &QualifiedNameAndType)
pub fn add_type(&self, name: &QualifiedNameAndType)
Add named types to the type archive. Type must have all dependant named types added prior to being added, or this function will fail. If the type already exists, it will be overwritten.
name
- Name of new typetype
- Definition of new type
sourcepub fn add_types(&self, new_types: &[QualifiedNameAndType])
pub fn add_types(&self, new_types: &[QualifiedNameAndType])
Add named types to the type archive. Types must have all dependant named types prior to being added, or included in the list, or this function will fail. Types already existing with any added names will be overwritten.
new_types
- Names and definitions of new types
sourcepub fn rename_type(
&self,
old_name: &QualifiedName,
new_name: &QualifiedNameAndType
)
pub fn rename_type( &self, old_name: &QualifiedName, new_name: &QualifiedNameAndType )
Change the name of an existing type in the type archive.
old_name
- Old type name in archivenew_name
- New type name
sourcepub fn rename_type_by_id<S: BnStrCompatible>(
&self,
id: S,
new_name: &QualifiedName
)
pub fn rename_type_by_id<S: BnStrCompatible>( &self, id: S, new_name: &QualifiedName )
Change the name of an existing type in the type archive.
id
- Old id of type in archivenew_name
- New type name
sourcepub fn delete_type(&self, name: &QualifiedName)
pub fn delete_type(&self, name: &QualifiedName)
Delete an existing type in the type archive.
sourcepub fn delete_type_by_id<S: BnStrCompatible>(&self, id: S)
pub fn delete_type_by_id<S: BnStrCompatible>(&self, id: S)
Delete an existing type in the type archive.
sourcepub fn get_type_by_name<S: BnStrCompatible>(
&self,
name: &QualifiedName,
snapshot: S
) -> Option<Ref<Type>>
pub fn get_type_by_name<S: BnStrCompatible>( &self, name: &QualifiedName, snapshot: S ) -> Option<Ref<Type>>
Retrieve a stored type in the archive
name
- Type namesnapshot
- Snapshot id to search for types
sourcepub fn get_type_by_id<I: BnStrCompatible, S: BnStrCompatible>(
&self,
id: I,
snapshot: S
) -> Option<Ref<Type>>
pub fn get_type_by_id<I: BnStrCompatible, S: BnStrCompatible>( &self, id: I, snapshot: S ) -> Option<Ref<Type>>
Retrieve a stored type in the archive by id
id
- Type idsnapshot
- Snapshot id to search for types
sourcepub fn get_type_name_by_id<I: BnStrCompatible, S: BnStrCompatible>(
&self,
id: I,
snapshot: S
) -> QualifiedName
pub fn get_type_name_by_id<I: BnStrCompatible, S: BnStrCompatible>( &self, id: I, snapshot: S ) -> QualifiedName
Retrieve a type’s name by its id
id
- Type idsnapshot
- Snapshot id to search for types
sourcepub fn get_type_id<S: BnStrCompatible>(
&self,
name: &QualifiedName,
snapshot: S
) -> Option<BnString>
pub fn get_type_id<S: BnStrCompatible>( &self, name: &QualifiedName, snapshot: S ) -> Option<BnString>
Retrieve a type’s id by its name
name
- Type namesnapshot
- Snapshot id to search for types
sourcepub fn get_types_and_ids<S: BnStrCompatible>(
&self,
snapshot: S
) -> Array<QualifiedNameTypeAndId>
pub fn get_types_and_ids<S: BnStrCompatible>( &self, snapshot: S ) -> Array<QualifiedNameTypeAndId>
Retrieve all stored types in the archive at a snapshot
snapshot
- Snapshot id to search for types
sourcepub fn get_type_ids<S: BnStrCompatible>(&self, snapshot: S) -> Array<BnString>
pub fn get_type_ids<S: BnStrCompatible>(&self, snapshot: S) -> Array<BnString>
Get a list of all types’ ids in the archive at a snapshot
snapshot
- Snapshot id to search for types
sourcepub fn get_type_names<S: BnStrCompatible>(
&self,
snapshot: S
) -> Array<QualifiedName>
pub fn get_type_names<S: BnStrCompatible>( &self, snapshot: S ) -> Array<QualifiedName>
Get a list of all types’ names in the archive at a snapshot
snapshot
- Snapshot id to search for types
sourcepub fn get_type_names_and_ids<S: BnStrCompatible>(
&self,
snapshot: S
) -> (Array<QualifiedName>, Array<BnString>)
pub fn get_type_names_and_ids<S: BnStrCompatible>( &self, snapshot: S ) -> (Array<QualifiedName>, Array<BnString>)
Get a list of all types’ names and ids in the archive at a current snapshot
snapshot
- Snapshot id to search for types
sourcepub fn get_outgoing_direct_references<I: BnStrCompatible, S: BnStrCompatible>(
&self,
id: I,
snapshot: S
) -> Array<BnString>
pub fn get_outgoing_direct_references<I: BnStrCompatible, S: BnStrCompatible>( &self, id: I, snapshot: S ) -> Array<BnString>
Get all types a given type references directly
id
- Source type idsnapshot
- Snapshot id to search for types
sourcepub fn get_outgoing_recursive_references<I: BnStrCompatible, S: BnStrCompatible>(
&self,
id: I,
snapshot: S
) -> Array<BnString>
pub fn get_outgoing_recursive_references<I: BnStrCompatible, S: BnStrCompatible>( &self, id: I, snapshot: S ) -> Array<BnString>
Get all types a given type references, and any types that the referenced types reference
:param id: Source type id :param snapshot: Snapshot id to search for types
sourcepub fn get_incoming_direct_references<I: BnStrCompatible, S: BnStrCompatible>(
&self,
id: I,
snapshot: S
) -> Array<BnString>
pub fn get_incoming_direct_references<I: BnStrCompatible, S: BnStrCompatible>( &self, id: I, snapshot: S ) -> Array<BnString>
Get all types that reference a given type
id
- Target type idsnapshot
- Snapshot id to search for types
sourcepub fn get_incoming_recursive_references<I: BnStrCompatible, S: BnStrCompatible>(
&self,
id: I,
snapshot: S
) -> Array<BnString>
pub fn get_incoming_recursive_references<I: BnStrCompatible, S: BnStrCompatible>( &self, id: I, snapshot: S ) -> Array<BnString>
Get all types that reference a given type, and all types that reference them, recursively
id
- Target type idsnapshot
- Snapshot id to search for types, or empty string to search the latest snapshot
sourcepub fn query_metadata<S: BnStrCompatible>(
&self,
key: S
) -> Option<Ref<Metadata>>
pub fn query_metadata<S: BnStrCompatible>( &self, key: S ) -> Option<Ref<Metadata>>
Look up a metadata entry in the archive
sourcepub fn store_metadata<S: BnStrCompatible>(&self, key: S, md: &Metadata)
pub fn store_metadata<S: BnStrCompatible>(&self, key: S, md: &Metadata)
Store a key/value pair in the archive’s metadata storage
key
- key value to associate the Metadata object withmd
- object to store.
sourcepub fn remove_metadata<S: BnStrCompatible>(&self, key: S) -> bool
pub fn remove_metadata<S: BnStrCompatible>(&self, key: S) -> bool
Delete a given metadata entry in the archive from the key
sourcepub fn serialize_snapshot<S: BnStrCompatible>(&self, snapshot: S) -> DataBuffer
pub fn serialize_snapshot<S: BnStrCompatible>(&self, snapshot: S) -> DataBuffer
Turn a given snapshot
id into a data stream
sourcepub fn deserialize_snapshot(&self, data: &DataBuffer) -> BnString
pub fn deserialize_snapshot(&self, data: &DataBuffer) -> BnString
Take a serialized snapshot data
stream and create a new snapshot from it
sourcepub fn register_notification_callback<T: TypeArchiveNotificationCallback>(
&self,
callback: T
) -> TypeArchiveCallbackHandle<T>
pub fn register_notification_callback<T: TypeArchiveNotificationCallback>( &self, callback: T ) -> TypeArchiveCallbackHandle<T>
Register a notification listener
pub fn register_notification_closure<A, U, R, D>(
&self,
type_added: A,
type_updated: U,
type_renamed: R,
type_deleted: D
) -> TypeArchiveCallbackHandle<NotificationClosure<A, U, R, D>>where
A: FnMut(&TypeArchive, &str, &Type),
U: FnMut(&TypeArchive, &str, &Type, &Type),
R: FnMut(&TypeArchive, &str, &QualifiedName, &QualifiedName),
D: FnMut(&TypeArchive, &str, &Type),
sourcepub fn close(self)
pub fn close(self)
Close a type archive, disconnecting it from any active views and closing any open file handles
sourcepub fn is_type_archive<P: BnStrCompatible>(file: P) -> bool
pub fn is_type_archive<P: BnStrCompatible>(file: P) -> bool
Determine if file
is a Type Archive
sourcepub fn new_snapshot_transaction<P, F>(
&self,
function: F,
parents: &[BnString]
) -> BnString
pub fn new_snapshot_transaction<P, F>( &self, function: F, parents: &[BnString] ) -> BnString
Do some function in a transaction making a new snapshot whose id is passed to func. If func throws, the transaction will be rolled back and the snapshot will not be created.
func
- Function to callparents
- Parent snapshot ids
Returns Created snapshot id
sourcepub fn merge_snapshots<B, F, S, P, M, MI, MK>(
&self,
base_snapshot: B,
first_snapshot: F,
second_snapshot: S,
merge_conflicts: M,
progress: P
) -> Result<BnString, Array<BnString>>where
B: BnStrCompatible,
F: BnStrCompatible,
S: BnStrCompatible,
P: FnMut(usize, usize) -> bool,
M: IntoIterator<Item = (MI, MK)>,
MI: BnStrCompatible,
MK: BnStrCompatible,
pub fn merge_snapshots<B, F, S, P, M, MI, MK>(
&self,
base_snapshot: B,
first_snapshot: F,
second_snapshot: S,
merge_conflicts: M,
progress: P
) -> Result<BnString, Array<BnString>>where
B: BnStrCompatible,
F: BnStrCompatible,
S: BnStrCompatible,
P: FnMut(usize, usize) -> bool,
M: IntoIterator<Item = (MI, MK)>,
MI: BnStrCompatible,
MK: BnStrCompatible,
Merge two snapshots in the archive to produce a new snapshot
base_snapshot
- Common ancestor of snapshotsfirst_snapshot
- First snapshot to mergesecond_snapshot
- Second snapshot to mergemerge_conflicts
- List of all conflicting types, id <-> target snapshotprogress
- Function to call for progress updates
Returns Snapshot id, if merge was successful, otherwise the List of conflicting type ids