Contract establishment with type and trait implementation

⚓ Rust    📅 2025-10-15    👤 surdeus    👁️ 1      

surdeus

How do I establish following contract in embedded rust project

**LibContract** crate
Pub struct BenCon;

Pub trait BenTrait {
 Fn1,
Fn2,
}

library crate Lib1 uses libCronract and should Provide BenCon structure type and implement BenTrait on it ?

Now this violates the orphan rule in rust. With C background, i am thinking in C. what would be correct idiomatic rust way of getting this done. What changes should I do? Here is my requirement, main application (binary crate) either can provide a reference to a BenCon object it created or can get BenCon object from lib1 and invoke methods on it. But the type and trait defintion can only reside in LibContract crate.

2 posts - 2 participants

Read full topic

🏷️ Rust_feed