pub struct ComponentRegistry { /* private fields */ }Expand description
Registry for managing component templates.
Implementations§
Source§impl ComponentRegistry
impl ComponentRegistry
Sourcepub fn register(&mut self, path: &str, template: &str) -> Result<(), Error>
pub fn register(&mut self, path: &str, template: &str) -> Result<(), Error>
Registers a component with its template.
Sourcepub fn resolve_tag(&self, tag: &str) -> Option<String>
pub fn resolve_tag(&self, tag: &str) -> Option<String>
Resolves a tag name to a component path.
Tries multiple variations: exact match, with “components/” prefix, with “.html” extension, and nested paths.
Sourcepub fn list_components(&self) -> Vec<String>
pub fn list_components(&self) -> Vec<String>
Lists all registered component paths.
Sourcepub fn validate_props(
&self,
path: &str,
provided: &Value,
) -> Result<HashMap<String, Value>, String>
pub fn validate_props( &self, path: &str, provided: &Value, ) -> Result<HashMap<String, Value>, String>
Validates props against a component’s prop definitions.
§Errors
Returns an error if a required prop is missing or a prop has an invalid type.
Sourcepub fn enable_cache(&mut self, enabled: bool)
pub fn enable_cache(&mut self, enabled: bool)
Enables or disables component caching.
Sourcepub fn is_cache_enabled(&self) -> bool
pub fn is_cache_enabled(&self) -> bool
Returns whether caching is enabled.
Sourcepub fn get_cached(&self, key: u64) -> Option<String>
pub fn get_cached(&self, key: u64) -> Option<String>
Gets a cached render.
Sourcepub fn set_cached(&self, key: u64, html: String, props_hash: u64)
pub fn set_cached(&self, key: u64, html: String, props_hash: u64)
Stores a render in the cache.
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Clears the component cache.
Trait Implementations§
Source§impl Clone for ComponentRegistry
impl Clone for ComponentRegistry
Source§fn clone(&self) -> ComponentRegistry
fn clone(&self) -> ComponentRegistry
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for ComponentRegistry
impl Default for ComponentRegistry
Source§fn default() -> ComponentRegistry
fn default() -> ComponentRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ComponentRegistry
impl RefUnwindSafe for ComponentRegistry
impl Send for ComponentRegistry
impl Sync for ComponentRegistry
impl Unpin for ComponentRegistry
impl UnsafeUnpin for ComponentRegistry
impl UnwindSafe for ComponentRegistry
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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