summaryrefslogtreecommitdiff
path: root/rust/src
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/platform.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/rust/src/platform.rs b/rust/src/platform.rs
index 013f709d..1bbdef4e 100644
--- a/rust/src/platform.rs
+++ b/rust/src/platform.rs
@@ -173,6 +173,10 @@ impl Platform {
unsafe { TypeContainer::from_raw(type_container_ptr.unwrap()) }
}
+ /// Get all the type libraries that have been registered with the name.
+ ///
+ /// NOTE: This is a list because libraries can have `alternate_names`, use [`Platform::get_type_library_by_name`]
+ /// if you want to get _the_ type library with that name, skipping alternate names.
pub fn get_type_libraries_by_name(&self, name: &str) -> Array<TypeLibrary> {
let mut count = 0;
let name = name.to_cstr();
@@ -182,6 +186,17 @@ impl Platform {
unsafe { Array::new(result, count, ()) }
}
+ /// Get the type library with the given name.
+ ///
+ /// NOTE: This finds the first type library that has the given name, skipping alternate names.
+ pub fn get_type_library_by_name(&self, name: &str) -> Option<Ref<TypeLibrary>> {
+ let libraries = self.get_type_libraries_by_name(name);
+ libraries
+ .iter()
+ .find(|lib| lib.name() == name)
+ .map(|lib| lib.to_owned())
+ }
+
pub fn register_os(&self, os: &str) {
let os = os.to_cstr();
unsafe {