pub trait Resource:
Send
+ Sync
+ Debug
+ 'static {
// Required methods
fn close(&self) -> ValueResult<()>;
fn is_closed(&self) -> bool;
fn resource_type(&self) -> &'static str;
fn as_any(&self) -> &dyn Any;
}Expand description
A closeable, ref-counted resource (file handle, socket, etc.).
All methods take &self because the inner state is behind a Mutex.
Required Methods§
Sourcefn close(&self) -> ValueResult<()>
fn close(&self) -> ValueResult<()>
Close the resource. Idempotent — calling on an already-closed resource is a no-op.
Sourcefn resource_type(&self) -> &'static str
fn resource_type(&self) -> &'static str
A short tag for display, e.g. "reader", "writer".