pub trait OwnedItem: Sized + Send {
type Accepted: Send;
type Rejection: Send;
type Prerequisite: Send;
// Provided method
fn retain_accepted(_: Self::Accepted) -> Option<Self::Accepted> { ... }
}Expand description
An action item interpreted as one whole owned input and an outside reply.
The interpreter borrows Option<Self> and its independent reply destination.
It consumes the input only when it can preserve either the accepted value or
the complete rejected, blocked or corrupt item in that destination. Dropping
an interpretation future before consumption leaves the original input owned
by the caller. Preparation and finalization use prepare_item and
finish_item; they do not invoke an interpreter or move sibling items.
Implement ActionItem directly when interpretation needs a different
custody or input equation. Implement this trait when the standard whole-item
loan is the complete contract; the ActionItem implementation is supplied.
struct OpenFile { path: std::path::PathBuf }
impl behavior::OwnedItem for OpenFile {
type Accepted = std::fs::File;
type Rejection = std::io::Error;
type Prerequisite = behavior::Never;
fn retain_accepted(file: std::fs::File) -> Option<std::fs::File> {
Some(file)
}
}The request can now be interpreted through InterpretItem without copying
custody aliases or preparation/finalization. Its file remains owned during
source settlement; ordinary receipts use the default discharge policy.
Required Associated Types§
Provided Methods§
Sourcefn retain_accepted(_: Self::Accepted) -> Option<Self::Accepted>
fn retain_accepted(_: Self::Accepted) -> Option<Self::Accepted>
Retain an accepted receipt only while it carries terminal custody.
Returning Some preserves the same owned value on subsequent source
offers. The default discharges the receipt, as in ActionItem.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".