diff options
| author | Mason Reed <mason@vector35.com> | 2025-05-12 15:56:33 -0400 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2025-05-12 17:45:24 -0400 |
| commit | 3ca989c48d07bb2f3f8a10aad07d7033d7478e00 (patch) | |
| tree | cbb95c69047a24ba05d80585728ae2eb7251e7f5 /rust/src/platform.rs | |
| parent | 1dcb19abc006a4fe0688934c8a08f0b4c61a75b2 (diff) | |
[Rust] Add `Platform::get_type_library_by_name`
Diffstat (limited to 'rust/src/platform.rs')
| -rw-r--r-- | rust/src/platform.rs | 15 |
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 { |
