pub struct TemplateStore<T> {
pub error: Option<String>,
/* private fields */
}Expand description
Named, host-readable templates. Without a storage service they live in memory. With a service attached, poll every frame, including while the template UI is closed. A failed read or an unknown document version disables writes until a successful reload, preventing accidental replacement of documents that could not be understood.
Fields§
§error: Option<String>Last storage or document error. Failed saves retain the edited template in memory.
Implementations§
Source§impl<T: Clone + Serialize + DeserializeOwned> TemplateStore<T>
impl<T: Clone + Serialize + DeserializeOwned> TemplateStore<T>
Sourcepub fn new(kind: StoreKind) -> Self
pub fn new(kind: StoreKind) -> Self
An empty catalog in the supplied namespace, initially kept only in memory.
Sourcepub fn entries(&self) -> &BTreeMap<String, T>
pub fn entries(&self) -> &BTreeMap<String, T>
Read the catalog, sorted by name, for a host-provided menu or export.
Sourcepub fn ready(&self) -> bool
pub fn ready(&self) -> bool
Whether saving, loading or deleting can begin. Reads must finish before writes start.
Sourcepub fn set_storage(&mut self, storage: Arc<dyn Storage>)
pub fn set_storage(&mut self, storage: Arc<dyn Storage>)
Attach the host storage service and read its catalog. No document is written on attach.
Sourcepub fn reload(&mut self)
pub fn reload(&mut self)
Retry reading the catalog after a failed read. While a request is outstanding this does nothing, so reloading cannot race a write or discard an unsaved edit.
Sourcepub fn poll(&mut self, ctx: &Context)
pub fn poll(&mut self, ctx: &Context)
Receive storage answers and wake the UI when the next asynchronous answer arrives.
Auto Trait Implementations§
impl<T> !RefUnwindSafe for TemplateStore<T>
impl<T> !UnwindSafe for TemplateStore<T>
impl<T> Freeze for TemplateStore<T>
impl<T> Send for TemplateStore<T>where
T: Send,
impl<T> Sync for TemplateStore<T>where
T: Sync,
impl<T> Unpin for TemplateStore<T>
impl<T> UnsafeUnpin for TemplateStore<T>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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