pub trait Resource: Sized {
type Event;
type Request;
fn interface() -> &'static Interface;
fn id(&self) -> ObjectId;
fn version(&self) -> u32;
fn data<U: 'static>(&self) -> Option<&U>;
fn object_data(&self) -> Option<&Arc<dyn Any + Send + Sync>>;
fn handle(&self) -> &WeakHandle;
fn from_id(dh: &DisplayHandle, id: ObjectId) -> Result<Self, InvalidId>;
fn send_event(&self, evt: Self::Event) -> Result<(), InvalidId>;
fn parse_request(
dh: &DisplayHandle,
msg: Message<ObjectId>
) -> Result<(Self, Self::Request), DispatchError>;
fn write_event(
&self,
dh: &DisplayHandle,
req: Self::Event
) -> Result<Message<ObjectId>, InvalidId>;
fn post_error(
&self,
dh: &DisplayHandle,
code: impl Into<u32>,
error: impl Into<String>
) { ... }
}