pub trait NativeObject:
Send
+ Sync
+ Debug
+ Trace
+ 'static {
// Required methods
fn type_tag(&self) -> &str;
fn as_any(&self) -> &dyn Any;
}Expand description
An opaque Rust value that can be wrapped as a Clojure Value::NativeObject.
Implementors must be Send + Sync (shared across threads), Debug
(for display), and Trace (so the GC can walk any GcPtr/Value
references held inside).
§Example
ⓘ
struct Counter { n: AtomicI64 }
impl NativeObject for Counter {
fn type_tag(&self) -> &str { "Counter" }
fn as_any(&self) -> &dyn Any { self }
}
// Trace is a no-op if the struct holds no GcPtr/Value fields.
impl Trace for Counter {
fn trace(&self, _: &mut MarkVisitor) {}
}