Implement native InventoryExplorer
All checks were successful
Native Rust workspace compile / compile (push) Successful in 21m44s

This commit is contained in:
2026-08-11 09:01:42 +00:00
parent 4504abcc64
commit bb7f419ca0
7 changed files with 1456 additions and 21 deletions

View File

@@ -214,6 +214,11 @@ pub trait InventoryObjectClass: std::any::Any {
/// Returns the shared `InventoryBase` portion of the concrete object.
fn inventory_base(&self) -> &InventoryBase;
/// Returns the shared `InventoryItem` portion for item-derived objects.
fn inventory_item(&self) -> Option<&InventoryItem> {
None
}
}
/// Rust object-safe view of concrete classes derived from C# `InventoryItem`.
@@ -233,6 +238,24 @@ macro_rules! inventory_object_class {
};
}
macro_rules! inventory_item_class {
($type:ty, $item:ident $(.$nested:ident)*) => {
impl InventoryObjectClass for $type {
fn as_any(&self) -> &dyn std::any::Any {
self
}
fn inventory_base(&self) -> &InventoryBase {
&self.$item$(.$nested)*.base
}
fn inventory_item(&self) -> Option<&InventoryItem> {
Some(&self.$item$(.$nested)*)
}
}
};
}
impl InventoryObjectClass for InventoryBase {
fn as_any(&self) -> &dyn std::any::Any {
self
@@ -244,22 +267,34 @@ impl InventoryObjectClass for InventoryBase {
}
inventory_object_class!(InventoryFolder, base);
inventory_object_class!(InventoryItem, base);
inventory_object_class!(InventoryAnimation, base.base);
inventory_object_class!(InventoryAttachment, base.base);
inventory_object_class!(InventoryCallingCard, base.base);
inventory_object_class!(InventoryCategory, base.base);
inventory_object_class!(InventoryGesture, base.base);
inventory_object_class!(InventoryLSL, base.base);
inventory_object_class!(InventoryLandmark, base.base);
inventory_object_class!(InventoryMaterial, base.base);
inventory_object_class!(InventoryNotecard, base.base);
inventory_object_class!(InventoryObject, base.base);
inventory_object_class!(InventorySettings, base.base);
inventory_object_class!(InventorySnapshot, base.base);
inventory_object_class!(InventorySound, base.base);
inventory_object_class!(InventoryTexture, base.base);
inventory_object_class!(InventoryWearable, base.base);
impl InventoryObjectClass for InventoryItem {
fn as_any(&self) -> &dyn std::any::Any {
self
}
fn inventory_base(&self) -> &InventoryBase {
&self.base
}
fn inventory_item(&self) -> Option<&InventoryItem> {
Some(self)
}
}
inventory_item_class!(InventoryAnimation, base);
inventory_item_class!(InventoryAttachment, base);
inventory_item_class!(InventoryCallingCard, base);
inventory_item_class!(InventoryCategory, base);
inventory_item_class!(InventoryGesture, base);
inventory_item_class!(InventoryLSL, base);
inventory_item_class!(InventoryLandmark, base);
inventory_item_class!(InventoryMaterial, base);
inventory_item_class!(InventoryNotecard, base);
inventory_item_class!(InventoryObject, base);
inventory_item_class!(InventorySettings, base);
inventory_item_class!(InventorySnapshot, base);
inventory_item_class!(InventorySound, base);
inventory_item_class!(InventoryTexture, base);
inventory_item_class!(InventoryWearable, base);
impl InventoryItemClass for InventoryItem {}
impl InventoryItemClass for InventoryAnimation {}