Skip to main content

LensRegistry

Struct LensRegistry 

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

A registry of lenses with a single shared dispatcher.

Implementations§

Source§

impl LensRegistry

Source

pub fn new() -> Self

An empty registry.

Source

pub fn register(&mut self, lens: Lens)

Register a lens (last registration of an id wins on exact ties).

Source

pub fn get(&self, id: &Symbol) -> Option<&Lens>

Look up a lens by id.

Source

pub fn lenses(&self) -> &[Lens]

All registered lenses.

Source

pub fn dispatch_view( &self, cx: &mut Cx, target: &Expr, ctx: &DispatchContext<'_>, ) -> Result<DispatchOutcome>

Dispatch a View lens for target.

Source

pub fn dispatch_editor( &self, cx: &mut Cx, target: &Expr, ctx: &DispatchContext<'_>, ) -> Result<DispatchOutcome>

Dispatch an Editor lens for target.

Source

pub fn dispatch( &self, cx: &mut Cx, kind: LensKind, target: &Expr, ctx: &DispatchContext<'_>, ) -> Result<DispatchOutcome>

Resolve a lens of kind for target per the documented order.

Source§

impl LensRegistry

Source

pub fn render_embedded( &self, cx: &mut Cx, lens_id: &Symbol, value: &Expr, ) -> Result<Expr>

Render value through the named view lens and return it wrapped in a scene/embed node, ready to nest inside a host lens’s Scene.

Source§

impl LensRegistry

Source

pub fn render( &self, cx: &mut Cx, lens_id: &Symbol, value: &Expr, ) -> Result<Expr>

Render value through the named view lens, validating the emitted Scene.

Source

pub fn propose( &self, cx: &mut Cx, lens_id: &Symbol, value: &Expr, intent: &Expr, ) -> Result<Draft>

Fold an Intent into a draft through the named editor lens, after the Intent passes structural validation.

Source

pub fn commit( &self, cx: &mut Cx, lens_id: &Symbol, draft: &Draft, ) -> Result<Operation>

Commit a committable draft through the named editor lens.

Source§

impl LensRegistry

Source

pub fn lens_stack( &self, cx: &mut Cx, kind: LensKind, target: &Expr, ctx: &DispatchContext<'_>, ) -> Result<Vec<LensStackEntry>>

Build the ordered lens stack of kind for target: every eligible lens best first, with the universal default last. Capability-denied lenses are excluded.

Trait Implementations§

Source§

impl Default for LensRegistry

Source§

fn default() -> LensRegistry

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.