Skip to main content

ComponentRegistry

Struct ComponentRegistry 

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

The components and template hooks one application registered.

Implementations§

Source§

impl ComponentRegistry

Source

pub fn new(config: LivewireConfig) -> Self

An empty registry for an application configured with config.

Source

pub fn persistent( &mut self, guard: impl PersistentMiddleware + 'static, ) -> &mut Self

Registers a guard that runs on every update of a component mounted by a page.

The guard sees the update’s request and the page the component was mounted from, so a route guard the page ran runs again when the browser drives the component.

Source

pub fn hook( &mut self, callback: impl Fn(&HookEvent<'_>) + Send + Sync + 'static, ) -> &mut Self

Registers a lifecycle hook, which the pipeline runs at each step.

Hooks run in registration order, on every request, for every component.

Source

pub fn register<C: Component + Default>( &mut self, name: impl Into<String>, ) -> Result<&mut Self, RegistryError>

Registers a component under name.

§Errors

Fails when the name is invalid, or when another component already has it.

Source

pub fn register_with<C: Component + Default>( &mut self, name: impl Into<String>, factory: impl Fn() -> C + Send + Sync + 'static, ) -> Result<&mut Self, RegistryError>

Registers a component that is built by factory rather than by Default.

§Errors

Fails when the name is invalid, or when another component already has it.

Source

pub fn register_synth<S: Synth>(&mut self) -> Result<&mut Self, RegistryError>

Registers a synthesizer, so that a snapshot may name its key.

§Errors

Fails when another synthesizer already has the key.

Source

pub fn register_synth_key( &mut self, key: &'static str, ) -> Result<&mut Self, RegistryError>

Registers a synthesizer key that a field already names.

§Errors

Fails when another synthesizer already has the key.

Source

pub fn templates( &mut self, configure: impl Fn(&mut Environment<'static>) + Send + Sync + 'static, ) -> &mut Self

Adds a callback that configures the .livewire engine, such as filters of the application’s own.

Source

pub fn has_synth(&self, key: &str) -> bool

Whether a snapshot may name key as a synthesizer.

Source

pub fn synth_keys(&self) -> impl Iterator<Item = &'static str> + '_

The synthesizer keys the application registered.

Source

pub fn instantiate(&self, name: &str) -> Option<Box<dyn Component>>

A new instance of the component registered as name.

Source

pub fn wire_fields(&self, name: &str) -> Option<&'static [WireField]>

The wire-public fields of the component registered as name.

Source

pub fn names(&self) -> impl ExactSizeIterator<Item = &str>

The names of the registered components, in order.

Source

pub fn contains(&self, name: &str) -> bool

Whether a component is registered.

Source

pub fn template_configurators(&self) -> &[TemplateConfigurator]

The callbacks that configure the engine.

Source

pub fn config(&self) -> &LivewireConfig

The configuration the application froze the registry with.

Source

pub fn synthesize_placeholder(&self) -> bool

Whether the built-in placeholder renders a lazy component before it loads.

Source

pub fn without_placeholder(&mut self) -> &mut Self

Turns the built-in lazy placeholder off, for an application that renders its own.

Trait Implementations§

Source§

impl Debug for ComponentRegistry

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for ComponentRegistry

§

impl !UnwindSafe for ComponentRegistry

§

impl Forget for ComponentRegistry

§

impl Freeze for ComponentRegistry
where *const LeafNode<String, Registration> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, Registration)>>: Freeze, *const LeafNode<&'static str, SetValZST> is !null: Freeze, PhantomData<Box<(&'static str, SetValZST)>>: Freeze, *const u8 is !null: Freeze, PhantomData<Arc<dyn Fn(&mut Environment<'static>) + Send + Sync>>: Freeze, PhantomData<String>: Freeze, *const LeafNode<String, String> is !null: Freeze, PhantomData<Box<(String, String)>>: Freeze, PhantomData<u8>: Freeze, PhantomData<Arc<dyn for<'a> Fn(&HookEvent<'a>) + Send + Sync>>: Freeze, PhantomData<Arc<dyn PersistentMiddleware>>: Freeze,

§

impl Move for ComponentRegistry

§

impl Send for ComponentRegistry
where NodeRef<Owned, String, Registration, LeafOrInternal>: Send, BoxRaw<(String, Registration)>: Send, NodeRef<Owned, &'static str, SetValZST, LeafOrInternal>: Send, BoxRaw<(&'static str, SetValZST)>: Send, RawVecInner: Send, Arc<dyn Fn(&mut Environment<'static>) + Send + Sync>: Send, NodeRef<Owned, String, String, LeafOrInternal>: Send, BoxRaw<(String, String)>: Send, Arc<dyn for<'a> Fn(&HookEvent<'a>) + Send + Sync>: Send, Arc<dyn PersistentMiddleware>: Send,

§

impl Sync for ComponentRegistry
where NodeRef<Owned, String, Registration, LeafOrInternal>: Sync, BoxRaw<(String, Registration)>: Sync, NodeRef<Owned, &'static str, SetValZST, LeafOrInternal>: Sync, BoxRaw<(&'static str, SetValZST)>: Sync, RawVecInner: Sync, Arc<dyn Fn(&mut Environment<'static>) + Send + Sync>: Sync, NodeRef<Owned, String, String, LeafOrInternal>: Sync, BoxRaw<(String, String)>: Sync, Arc<dyn for<'a> Fn(&HookEvent<'a>) + Send + Sync>: Sync, Arc<dyn PersistentMiddleware>: Sync,

§

impl Unpin for ComponentRegistry
where *const LeafNode<String, Registration> is !null: Unpin, Box<(String, Registration)>: Unpin, *const LeafNode<&'static str, SetValZST> is !null: Unpin, Box<(&'static str, SetValZST)>: Unpin, *const u8 is !null: Unpin, Arc<dyn Fn(&mut Environment<'static>) + Send + Sync>: Unpin, *const LeafNode<String, String> is !null: Unpin, Box<(String, String)>: Unpin, Arc<dyn for<'a> Fn(&HookEvent<'a>) + Send + Sync>: Unpin, Arc<dyn PersistentMiddleware>: Unpin,

§

impl UnsafeUnpin for ComponentRegistry
where *const LeafNode<String, Registration> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(String, Registration)>>: UnsafeUnpin, *const LeafNode<&'static str, SetValZST> is !null: UnsafeUnpin, PhantomData<Box<(&'static str, SetValZST)>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<Arc<dyn Fn(&mut Environment<'static>) + Send + Sync>>: UnsafeUnpin, PhantomData<String>: UnsafeUnpin, *const LeafNode<String, String> is !null: UnsafeUnpin, PhantomData<Box<(String, String)>>: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, PhantomData<Arc<dyn for<'a> Fn(&HookEvent<'a>) + Send + Sync>>: UnsafeUnpin, PhantomData<Arc<dyn PersistentMiddleware>>: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

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

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

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, N> NotifiedBy<T> for N
where T: Notification<N>,

Source§

fn __routes(&self) -> Vec<Route>

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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