Struct muse_lang::runtime::value::RustTypeBuilder

source ·
pub struct RustTypeBuilder<T> { /* private fields */ }
Expand description

A builder for a RustType<T>.

Implementations§

source§

impl<T> RustTypeBuilder<T>
where T: CustomType + Trace,

source

pub fn with_construct<Func>( self, func: impl FnOnce(ConstructFn) -> Func, ) -> Self
where Func: Fn(&mut VmContext<'_, '_>, Arity) -> Result<Dynamic<T>, Fault> + Send + Sync + 'static,

Replaces the constructor with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_call<Func>(self, func: impl FnOnce(CallFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, Arity) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the call handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_function_table(self, functions: RustFunctionTable<T>) -> Self

Replaces the invoke handler with a handler that invokes the appropriate function.

source

pub fn with_invoke<Func>(self, func: impl FnOnce(InvokeFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &SymbolRef, Arity) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the invoke handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_hash<Func>(self, func: impl FnOnce(HashFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &mut ValueHasher) + Send + Sync + 'static,

Replaces the hash handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_bitwise_not<Func>(self, func: impl FnOnce(UnaryFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the bitwise not handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_bitwise_and<Func>(self, func: impl FnOnce(BinaryFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &Value) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the bitwise and with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_bitwise_or<Func>(self, func: impl FnOnce(BinaryFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &Value) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the bitwise or handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_bitwise_xor<Func>(self, func: impl FnOnce(BinaryFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &Value) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the bitwise xor handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_shift_left<Func>(self, func: impl FnOnce(BinaryFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &Value) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the shift left handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_shift_right<Func>(self, func: impl FnOnce(BinaryFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &Value) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the shift right handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_negate<Func>(self, func: impl FnOnce(UnaryFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the negate handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_eq<Func>(self, func: impl FnOnce(EqFn) -> Func) -> Self
where Func: Fn(Rooted<T>, ContextOrGuard<'_, '_, '_>, &Value) -> Result<bool, Fault> + Send + Sync + 'static,

Replaces the eq handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_matches<Func>(self, func: impl FnOnce(MatchesFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &Value) -> Result<bool, Fault> + Send + Sync + 'static,

Replaces the matches handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_total_cmp<Func>(self, func: impl FnOnce(TotalCmpFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &Value) -> Result<Ordering, Fault> + Send + Sync + 'static,

Replaces the comparison handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_add<Func>(self, func: impl FnOnce(BinaryFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &Value) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the add handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_add_right<Func>(self, func: impl FnOnce(BinaryFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &Value) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the add-right handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_sub<Func>(self, func: impl FnOnce(BinaryFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &Value) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the sub handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_sub_right<Func>(self, func: impl FnOnce(BinaryFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &Value) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the sub-right handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_mul<Func>(self, func: impl FnOnce(BinaryFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &Value) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the mul handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_mul_right<Func>(self, func: impl FnOnce(BinaryFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &Value) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the mul-right handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_div<Func>(self, func: impl FnOnce(BinaryFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &Value) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the div handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_div_right<Func>(self, func: impl FnOnce(BinaryFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &Value) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the div-right handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_idiv<Func>(self, func: impl FnOnce(BinaryFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &Value) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the idiv handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_idiv_right<Func>(self, func: impl FnOnce(BinaryFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &Value) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the idiv-right handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_rem<Func>(self, func: impl FnOnce(BinaryFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &Value) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the rem handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_rem_right<Func>(self, func: impl FnOnce(BinaryFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>, &Value) -> Result<Value, Fault> + Send + Sync + 'static,

Replaces the rem-right handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_truthy<Func>(self, func: impl FnOnce(TruthyFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>) -> bool + Send + Sync + 'static,

Replaces the truthy handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_to_string<Func>(self, func: impl FnOnce(ToStringFn) -> Func) -> Self
where Func: Fn(Rooted<T>, &mut VmContext<'_, '_>) -> Result<SymbolRef, Fault> + Send + Sync + 'static,

Replaces the to_string handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_deep_clone<Func>( self, func: impl FnOnce(DeepCloneFn) -> Func, ) -> Self
where Func: Fn(Rooted<T>, &CollectionGuard<'_>) -> Option<AnyDynamic> + Send + Sync + 'static,

Replaces the deep_clone handler with func.

func is a function that returns the actual handler function. It takes a single parameter: the existing handler. This design allows for functions to be overridden while still falling back to the previous implementation.

source

pub fn with_clone(self) -> Self
where T: Clone,

Replaces the deep_clone handler with an implementation that uses Clone.

source

pub fn with_fallback<Mapping>(self, mapping: Mapping) -> Self
where Mapping: Fn(Rooted<T>, &CollectionGuard<'_>) -> Value + Send + Sync + Clone + 'static,

Replaces all functions on this table by invoking mapping and invoking the corresponding functionality on the returned value.

Auto Trait Implementations§

§

impl<T> Freeze for RustTypeBuilder<T>

§

impl<T> !RefUnwindSafe for RustTypeBuilder<T>

§

impl<T> Send for RustTypeBuilder<T>
where T: Send,

§

impl<T> Sync for RustTypeBuilder<T>
where T: Sync,

§

impl<T> Unpin for RustTypeBuilder<T>
where T: Unpin,

§

impl<T> !UnwindSafe for RustTypeBuilder<T>

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
§

impl<A> Cast for A

§

fn cast<To>(self) -> To
where To: CastFrom<A>,

Casts self to the To type. This may be a lossy operation.
§

impl<A> CastFrom<A> for A

§

fn from_cast(from: A) -> A

Returns from as Self.
§

impl<A, B> CastInto<A> for B
where A: CastFrom<B>,

§

fn cast_into(self) -> A

Returns self as To.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more