Skip to main content

ComponentRegistry

Struct ComponentRegistry 

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

Registry of web components.

Implementations§

Source§

impl ComponentRegistry

Source

pub fn new() -> Self

Create a new component registry.

Source

pub fn register_from_paths<P: AsRef<Path>>( &mut self, directories: &[P], ) -> Result<&mut Self>

Register multiple components from directories recursively.

Source

pub fn register_component_from_paths<P: AsRef<Path>, Q: AsRef<Path>>( &mut self, html_path: P, css_path: Option<Q>, ) -> Result<()>

Register a web component from paths to HTML and CSS files.

Source

pub fn register_component( &mut self, registration: ComponentRegistration<'_>, ) -> Result<()>

Register a component directly from provided content strings.

Exact JavaScript state ownership is supplied later by a bundler projection manifest; the parser stores only whether this tag is client-owned.

Source

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

Check if a tag name is registered as a component.

Source

pub fn get(&self, tag_name: &str) -> Option<&Component>

Get a component by its tag name.

Source

pub fn get_all(&self) -> impl Iterator<Item = &Component>

Get all registered components.

Source

pub fn render_policy_css<'a>( &self, tag_names: impl IntoIterator<Item = &'a str>, ) -> String

Build deterministic document-level CSS for the supplied component tags that opt into browser-managed lazy rendering.

Source

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

Iterate the registered component tag names (e.g. mp-button).

Used to offer “did you mean …?” suggestions when an unknown component tag is encountered during parsing.

Source

pub fn len(&self) -> usize

Get the number of registered components.

Source

pub fn is_empty(&self) -> bool

Check if the registry has no registered components.

Trait Implementations§

Source§

impl Debug for ComponentRegistry

Source§

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

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

impl Default for ComponentRegistry

Source§

fn default() -> Self

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