Skip to main content

Registry

Struct Registry 

Source
pub struct Registry { /* private fields */ }
Expand description

Everything of the host program an interpreted program can reach.

Implementations§

Source§

impl Registry

Source

pub fn new() -> Self

An empty registry.

Source

pub fn function( &mut self, ty: &str, name: &str, f: impl Fn(Vec<Value>) -> Result<Value, String> + 'static, )

Type::name(..), taking the arguments as they are.

Source

pub fn method( &mut self, ty: &str, name: &str, f: impl Fn(Vec<Value>) -> Result<Value, String> + 'static, )

value.name(..) on a host value of ty; the receiver comes first.

Source

pub fn method_for<T: 'static>( &mut self, ty: &str, name: &str, f: impl Fn(Vec<Value>) -> Result<Value, String> + 'static, )

value.name(..) on a host value holding a T, for types that share a name, such as the forms of a generic component.

Source

pub fn constant( &mut self, ty: &str, name: &str, make: impl Fn() -> Value + 'static, )

Type::NAME, made each time it is read.

Source

pub fn free_function( &mut self, name: &str, f: impl Fn(Vec<Value>) -> Result<Value, String> + 'static, )

A function called by its name alone, such as a helper the samples share.

Source

pub fn field( &mut self, ty: &str, name: &str, get: impl Fn(&Value) -> Result<Value, String> + 'static, )

How value.name reads a field of a host struct of ty.

Source

pub fn set_field( &mut self, ty: &str, name: &str, set: impl Fn(&Value, Value) -> Result<(), String> + 'static, )

How value.name = .. changes a field of a host struct of ty.

Source

pub fn record( &mut self, ty: &str, build: impl Fn(Vec<(String, Value)>, Option<Value>) -> Result<Value, String> + 'static, )

How Ty { a: .., b: .., ..base } builds a host struct.

Source

pub fn name_type<T: 'static>(&mut self, name: &'static str)

Remembers which name a Rust type goes by, for conversions.

Source

pub fn conversion<From: 'static, To: 'static>( &mut self, name: &'static str, convert: fn(From) -> To, )

How a host value of type From becomes a To when a function asks for a To, as a Button becomes an AnyView.

Source

pub fn alias(&mut self, alias: &str, ty: &str)

Lets alias name the type registered as ty, as a crate re-exports Stack as ChartStack.

Trait Implementations§

Source§

impl Debug for Registry

Source§

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

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

impl Default for Registry

Source§

fn default() -> Registry

Returns the “default value” for a type. 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> 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, 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.