Skip to main content

Unit

Struct Unit 

Source
pub struct Unit {
    pub name: &'static str,
    pub kind: UnitKind,
    pub identity_path: &'static str,
    pub source: &'static str,
    pub binding: Binding,
    pub id_block: u32,
    pub platform: Option<Platform>,
    pub env_providers: &'static [&'static str],
    pub stability: Stability,
    pub experimental: &'static [&'static str],
    pub extensible: &'static [&'static str],
    pub instantiable: &'static [Instantiable],
}
Expand description

One first-party unit, as data (standard-library track, S1 #1945). Adding a unit to the standard library is an entry in UNITS plus its files; the checker’s injection reads this table and needs no change.

Fields§

§name: &'static str

The unit’s dotted name, inside the reserved bynk.* prefix.

§kind: UnitKind

Whether a project consumes it (an adapter) or uses it (a commons).

§identity_path: &'static str

The synthetic path the injected unit is parsed under. Diagnostics and emission name the unit by it, so it never changes.

§source: &'static str

The unit’s .bynk source.

§binding: Binding

The binding the toolchain supplies for it.

§id_block: u32

Its permanent ExprId block: the checker parses it at FIRSTPARTY_ID_BASE + id_block * FIRSTPARTY_ID_BLOCK, and injects units in ascending id_block order. A block is never reused or moved, so ids and injection order stay stable as units are added; a new unit takes the next free block.

§platform: Option<Platform>

The platform that consuming it locks a deployment unit to (decision 0024), if it is platform-native.

§env_providers: &'static [&'static str]

The provider classes whose constructor takes the Worker env (decisions 0021/0025).

§stability: Stability

The unit’s stability (track D2, S3 #1963): a stable item is under the 1.0 promise, an experimental one carries none and needs an explicit [unstable] allow to use. Required, so no entry is added without a choice.

§experimental: &'static [&'static str]

Items inside a stable unit that are experimental, as paths relative to the unit: an exported item ("Kv") or a capability operation ("Kv.list"). An experimental item makes its operations experimental.

§extensible: &'static [&'static str]

The exported enums that may gain variants in a minor release, so a match covering one needs a wildcard (track §11 Q5).

§instantiable: &'static [Instantiable]

The capabilities a context may declare named instances of with capability Sessions = Kv (S4a, #1966): each its own platform resource. A capability not listed (Workers AI’s single [ai] binding, say) has no instances.

Implementations§

Source§

impl Unit

Source

pub fn binding_for( &self, platform: Platform, ) -> Option<(&'static str, &'static str)>

The binding module to emit for this unit on platform, as (output path, source), or None for a commons.

Trait Implementations§

Source§

impl Clone for Unit

Source§

fn clone(&self) -> Self

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 Copy for Unit

Source§

impl Debug for Unit

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Unit

Source§

impl PartialEq for Unit

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Unit

Auto Trait Implementations§

§

impl Freeze for Unit

§

impl RefUnwindSafe for Unit

§

impl Send for Unit

§

impl Sync for Unit

§

impl Unpin for Unit

§

impl UnsafeUnpin for Unit

§

impl UnwindSafe for Unit

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.