pub struct MagicFunctions {
pub get: fn(FunctionCallContext, ReflectReference, ScriptValue) -> Result<ScriptValue, InteropError>,
pub set: fn(FunctionCallContext, ReflectReference, ScriptValue, ScriptValue) -> Result<(), InteropError>,
}Expand description
A list of magic methods, these only have one replacable implementation, and apply to all ReflectReferences.
It’s up to the language implementer to call these in the right order (after any type specific overrides).
These live in a separate mini registry since they are so commonly needed. This helps us avoid needless hashing and lookups as well as script value conversions
Fields§
§get: fn(FunctionCallContext, ReflectReference, ScriptValue) -> Result<ScriptValue, InteropError>Indexer function
set: fn(FunctionCallContext, ReflectReference, ScriptValue, ScriptValue) -> Result<(), InteropError>Indexer setter function
Implementations§
Source§impl MagicFunctions
impl MagicFunctions
Sourcepub fn get(
&self,
ctxt: FunctionCallContext,
reference: ReflectReference,
key: ScriptValue,
) -> Result<ScriptValue, InteropError>
pub fn get( &self, ctxt: FunctionCallContext, reference: ReflectReference, key: ScriptValue, ) -> Result<ScriptValue, InteropError>
Calls the currently set get function with the given arguments.
Sourcepub fn set(
&self,
ctxt: FunctionCallContext,
reference: ReflectReference,
key: ScriptValue,
value: ScriptValue,
) -> Result<(), InteropError>
pub fn set( &self, ctxt: FunctionCallContext, reference: ReflectReference, key: ScriptValue, value: ScriptValue, ) -> Result<(), InteropError>
Calls the currently set set function with the given arguments.
Sourcepub fn default_get(
ctxt: FunctionCallContext,
reference: ReflectReference,
key: ScriptValue,
) -> Result<ScriptValue, InteropError>
pub fn default_get( ctxt: FunctionCallContext, reference: ReflectReference, key: ScriptValue, ) -> Result<ScriptValue, InteropError>
Indexes into the given reference and if the nested type is a reference type, returns a deeper reference, otherwise returns the concrete value.
Does not support map types at the moment, for maps see map_get
Arguments:
ctxt: The function call context.reference: The reference to index into.key: The key to index with.
Returns:
value: The value at the key, if the reference is indexable.
Sourcepub fn default_set(
ctxt: FunctionCallContext,
reference: ReflectReference,
key: ScriptValue,
value: ScriptValue,
) -> Result<(), InteropError>
pub fn default_set( ctxt: FunctionCallContext, reference: ReflectReference, key: ScriptValue, value: ScriptValue, ) -> Result<(), InteropError>
Sets the value under the specified path on the underlying value.
Arguments:
ctxt: The function call context.reference: The reference to set the value on.key: The key to set the value at.value: The value to set.
Returns:
result: Nothing if the value was set successfully.
Trait Implementations§
Source§impl Debug for MagicFunctions
impl Debug for MagicFunctions
Source§impl DebugWithTypeInfo for MagicFunctions
impl DebugWithTypeInfo for MagicFunctions
Source§fn to_string_with_type_info(
&self,
f: &mut Formatter<'_>,
type_info_provider: Option<&WorldAccessGuard<'_>>,
) -> Result<(), Error>
fn to_string_with_type_info( &self, f: &mut Formatter<'_>, type_info_provider: Option<&WorldAccessGuard<'_>>, ) -> Result<(), Error>
Source§impl Default for MagicFunctions
impl Default for MagicFunctions
Source§fn default() -> MagicFunctions
fn default() -> MagicFunctions
Auto Trait Implementations§
impl Forget for MagicFunctions
impl Freeze for MagicFunctions
impl Move for MagicFunctions
impl RefUnwindSafe for MagicFunctions
impl Send for MagicFunctions
impl Sync for MagicFunctions
impl Unpin for MagicFunctions
impl UnsafeUnpin for MagicFunctions
impl UnwindSafe for MagicFunctions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ConditionalSend for Twhere
T: Send,
impl<T> Context for T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more