expression

Separate read and write service capabilities

A consumer that only queries data should not require a mutation API. Smaller traits can allow read-only adapters and make the required behavior clear. This is a type-level interface boundary, not a security sandbox: a concrete adapter might still have other methods. Add separate write authority checks when the application requires them. Expected result (NOT RUN): before: 2 after: 8 Common mistake: Requiring a broad read-write interface for code that only reads, or mistaking trait segregation for authorization. Static Rust example; not a verified ByteMind executable assessment.

Formal Syntax & Structure

rust syntaxrust
trait Lookup { ... }; trait Store { ... };

Working Example

Example Snippetrust
trait Lookup { fn get(&self) -> u32; }trait Store { fn set(&mut self, value: u32); }struct Counter(u32);impl Lookup for Counter { fn get(&self) -> u32 { self.0 } }impl Store for Counter { fn set(&mut self, value: u32) { self.0 = value; } }fn report(source: &impl Lookup) -> u32 { source.get() }fn main() {    let mut counter = Counter(2);    println!("before: {}", report(&counter));    counter.set(8);    println!("after: {}", report(&counter));}
Rust Reference