Skip to main content

Transfer

Enum Transfer 

Source
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

§type_name: String
§fields: Vec<(String, Transfer)>
§opaque: bool

Whether the type is opaque, so that a value rebuilt in the receiving task keeps rendering as its name alone.

§

Enum

Fields

§type_name: String
§case: String
§payload: Vec<Transfer>
§

Dyn

Fields

§trait_name: String
§value: Box<Transfer>
§

Closure(Box<TransferClosure>)

§

HostModule(String)

§

HostFn

Fields

§module: String
§

Type(String)

§

Range

Fields

§start: i64
§end: i64
§inclusive_end: bool
§

Shared(Arc<SharedCell>)

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

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Transfer

Source§

fn clone(&self) -> Transfer

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Transfer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.