mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-01-23 09:09:21 -05:00
Add codec setter to UseStorageOptions
This commit is contained in:
parent
64c6f63d68
commit
d267408116
1 changed files with 8 additions and 0 deletions
|
@ -382,6 +382,14 @@ impl<T: Default, C: Codec<T> + Default> Default for UseStorageOptions<T, C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Default, C: Codec<T>> UseStorageOptions<T, C> {
|
impl<T: Default, C: Codec<T>> UseStorageOptions<T, C> {
|
||||||
|
/// Sets the codec to use for encoding and decoding values to and from UTF-16 strings.
|
||||||
|
pub fn codec(self, codec: impl Into<C>) -> Self {
|
||||||
|
Self {
|
||||||
|
codec: codec.into(),
|
||||||
|
..self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Optional callback whenever an error occurs.
|
/// Optional callback whenever an error occurs.
|
||||||
pub fn on_error(self, on_error: impl Fn(UseStorageError<C::Error>) + 'static) -> Self {
|
pub fn on_error(self, on_error: impl Fn(UseStorageError<C::Error>) + 'static) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
Loading…
Add table
Reference in a new issue