I have the following Connection struct and a simple constructor function:
struct Connection;
impl Connection {
pub fn new() -> Connection {
// before constructor
let construct = Connection;
// after constructor
construct
}
}
I want to be able to register events that happen before/after creation of any Connection. For example.
register!(Connection, before, println!("Before 1"));
register!(Connection, before, println!("Before 2"));
register!(Connection, after, println!("After"));
So once I call Connection::new() it should at least attempt to write:
//out: Before 1
//out: Before 2
returns value
//out: After
I think this requires a static Observable class, but is that even possible in safe Rust?