pub struct Dependencies {
Show 16 fields pub needs_clamp: bool, pub needs_store: bool, pub needs_load: bool, pub needs_validate_guest_char: bool, pub needs_expected: bool, pub needs_i32_to_f32: bool, pub needs_f32_to_i32: bool, pub needs_i64_to_f64: bool, pub needs_f64_to_i64: bool, pub needs_decode_utf8: bool, pub needs_encode_utf8: bool, pub needs_list_canon_lift: bool, pub needs_list_canon_lower: bool, pub needs_t_typevar: bool, pub needs_resources: bool, pub pyimports: BTreeMap<String, Option<BTreeSet<String>>>,
}
Expand description

Tracks all of the import and intrinsics that a given codegen requires and how to generate them when needed.

Fields§

§needs_clamp: bool§needs_store: bool§needs_load: bool§needs_validate_guest_char: bool§needs_expected: bool§needs_i32_to_f32: bool§needs_f32_to_i32: bool§needs_i64_to_f64: bool§needs_f64_to_i64: bool§needs_decode_utf8: bool§needs_encode_utf8: bool§needs_list_canon_lift: bool§needs_list_canon_lower: bool§needs_t_typevar: bool§needs_resources: bool§pyimports: BTreeMap<String, Option<BTreeSet<String>>>

Implementations§

source§

impl Dependencies

source

pub fn pyimport<'a>(&mut self, module: &str, name: impl Into<Option<&'a str>>)

Record that a Python import is required

Examples

// Import a specific item from a module
deps.pyimport("typing", "NamedTuple");
// Import an entire module
deps.pyimport("collections", None);
source

pub fn intrinsics(&mut self) -> Source

Create a Source containing all of the intrinsics required according to this Dependencies struct.

Trait Implementations§

source§

impl Default for Dependencies

source§

fn default() -> Dependencies

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.