pub enum Transfer {
Show 19 variants
Unit,
Bool(bool),
Int(i64),
Float(f64),
Duration(i64),
Str(String),
Array(Vec<Transfer>),
Map(BTreeMap<MapKey, Transfer>),
Set(BTreeSet<MapKey>),
Struct {
type_name: String,
fields: Vec<(String, Transfer)>,
opaque: bool,
},
Enum {
type_name: String,
case: String,
payload: Vec<Transfer>,
},
Dyn {
trait_name: String,
value: Box<Transfer>,
},
Closure(Box<TransferClosure>),
HostModule(String),
HostFn {
module: String,
op: String,
},
Type(String),
Range {
start: i64,
end: i64,
inclusive_end: bool,
},
Shared(Arc<SharedCell>),
Resource(Arc<ResourceHandle>),
}Expand description
A task-safe value in the form the receiving task can own.
The interpreter’s Value is reference-counted with Rc, so it belongs
to the thread that built it, while a value crossing a task boundary has to
be owned by the thread that receives it. ADR 0008 observes that those are
one condition: the Language Card lets a value cross exactly when copying
it is the whole of transferring it, which is what a thread requires too.
So this is not a second task-safety rule standing beside the first — it
is the rule, and the walk that once only answered it was replaced by
this one. Transfer::of answers both questions in one walk: whether
the value may cross, and what the receiving task owns once it has.
Variants§
Unit
Bool(bool)
Int(i64)
Float(f64)
Duration(i64)
Str(String)
Array(Vec<Transfer>)
Map(BTreeMap<MapKey, Transfer>)
Set(BTreeSet<MapKey>)
Struct
Fields
Enum
Dyn
Closure(Box<TransferClosure>)
HostModule(String)
HostFn
Type(String)
Range
The one value that crosses by sharing rather than by copying: both
sides address the same SharedCell, which is what makes Shared
the sanctioned way to hold mutable state across tasks.
Resource(Arc<ResourceHandle>)
A resource handle, when its schema says it may cross.
A handle is a name and nothing else, so it crosses the way a string
does. What decides is not the handle but the resource: a host that
keeps a connection behind a lock says so in its
crate::schema::ResourceSchema, and the answer travels on the
handle so this walk can read it.
Implementations§
Source§impl Transfer
impl Transfer
Sourcepub fn of(value: &Value) -> Result<Transfer, NotTaskSafe>
pub fn of(value: &Value) -> Result<Transfer, NotTaskSafe>
Converts value into the form a receiving task owns, or reports the
first part of it that may not cross a task boundary.
Sourcepub fn into_value(self) -> Value
pub fn into_value(self) -> Value
Rebuilds the value in the receiving task, where it is an ordinary
Value again with no trace of having crossed.