pub trait HandleProtocol:
Send
+ Sync
+ 'static {
type Handle: Send + Sync + 'static;
// Required methods
fn open(&self, cx: HandleCx, request: Value) -> Result<Self::Handle, Error>;
fn read(
&self,
handle: Arc<Self::Handle>,
sub: Path,
) -> DetachedFuture<Option<Record>>;
fn write(
&self,
handle: Arc<Self::Handle>,
sub: Path,
data: Record,
) -> DetachedFuture<Path>;
// Provided methods
fn close(&self, handle: Arc<Self::Handle>) { ... }
fn docs(&self) -> Option<Value> { ... }
}Expand description
The store-specific half of a handle store.
Implementations define per-handle state and the meaning of sub-paths
under outstanding/{id}. All routing and lifecycle is handled by
HandleStore.
Required Associated Types§
Required Methods§
Sourcefn open(&self, cx: HandleCx, request: Value) -> Result<Self::Handle, Error>
fn open(&self, cx: HandleCx, request: Value) -> Result<Self::Handle, Error>
Open a handle for a request written to the store root.
Spawn any background work here; keep cx.cancel if parked reads
need to fail on release.
Sourcefn read(
&self,
handle: Arc<Self::Handle>,
sub: Path,
) -> DetachedFuture<Option<Record>>
fn read( &self, handle: Arc<Self::Handle>, sub: Path, ) -> DetachedFuture<Option<Record>>
Serve a read below the handle. sub is relative to the handle
(empty for a read of outstanding/{id} itself).
Sourcefn write(
&self,
handle: Arc<Self::Handle>,
sub: Path,
data: Record,
) -> DetachedFuture<Path>
fn write( &self, handle: Arc<Self::Handle>, sub: Path, data: Record, ) -> DetachedFuture<Path>
Serve a write below the handle. The returned path is relative to
the handle; HandleStore prefixes outstanding/{id} so callers
always see paths in their own namespace.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".