pub struct Session {
pub agents: Vec<SavedAgent>,
pub saved: BTreeMap<String, Value>,
pub repairs: Vec<Repair>,
}Expand description
A session as its logs left it.
Fields§
§agents: Vec<SavedAgent>Its agents, in the order their logs were started.
saved: BTreeMap<String, Value>The session’s own saved values by key: the SESSION log’s.
repairs: Vec<Repair>What reading it repaired or worked around.
Implementations§
Source§impl Session
impl Session
Sourcepub fn value<T>(&self, key: &str) -> Option<Result<T, Error>>where
T: DeserializeOwned,
pub fn value<T>(&self, key: &str) -> Option<Result<T, Error>>where
T: DeserializeOwned,
The session’s own saved value under key (the SESSION
log’s), read as a T: None when it has none, an error when the
value is not a T.
Sourcepub fn main_agent(&self) -> Option<&SavedAgent>
pub fn main_agent(&self) -> Option<&SavedAgent>
The main agent: the first by main_order of the agents a restore
brings back (not retired, nor spawned by one retired).
Source§impl Session
impl Session
Sourcepub fn read(store: &(dyn Store + 'static)) -> Result<Session, SessionError>
pub fn read(store: &(dyn Store + 'static)) -> Result<Session, SessionError>
Reads the session kept in store, without writing to it: a torn
last line is reported and left. Retired agents are read too.
§Errors
When the store fails, or any log is in another format or holds a record that cannot be read or does not apply: the whole session is refused.
Sourcepub fn read_lenient(
store: &(dyn Store + 'static),
) -> Result<(Session, Vec<Unreadable>), SessionError>
pub fn read_lenient( store: &(dyn Store + 'static), ) -> Result<(Session, Vec<Unreadable>), SessionError>
Reads each log of the session kept in store that reads, as
Self::read does, and sets aside each that does not, with why:
for a reader that shows what it can, such as an export or a search.
A restore reads strictly, so it never goes on from part of a
session.
§Errors
When the store cannot list its logs.
Sourcepub fn agent(&self, id: &str) -> Option<&SavedAgent>
pub fn agent(&self, id: &str) -> Option<&SavedAgent>
The agent id.
Sourcepub fn agent_mut(&mut self, id: &str) -> Option<&mut SavedAgent>
pub fn agent_mut(&mut self, id: &str) -> Option<&mut SavedAgent>
The agent id, to change it.
Sourcepub fn save(
&mut self,
store: &(dyn Store + 'static),
) -> Result<(), SessionError>
pub fn save( &mut self, store: &(dyn Store + 'static), ) -> Result<(), SessionError>
Saves the session to store, the one it was read from (or an empty
one): appends each agent’s unsaved changes (an agent new to the
store gets a header), its changed and removed saved values, and its
retirement, and the session’s changed values. Each agent’s
conversation is left with nothing unsaved. A torn last line of a log
written to is first set aside, as Writer::open
does.
§Errors
SessionError::Changed when a log that holds changes moved on since
the agent’s conversation was read, or holds another conversation,
before anything is written; when the store fails, a log is in another
format, or a line has no stamp; or when a write fails. It reads the
stamps of the logs’ changes, not the changes, so a change that does
not apply is refused by Self::read, not here.
Trait Implementations§
impl StructuralPartialEq for Session
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl UnwindSafe for Session
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> FromTemplate for T
impl<T> FromTemplate for T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Template for T
impl<T> Template for T
Source§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a Template::Output.Source§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.Source§impl<T> TypeData for T
impl<T> TypeData for T
Source§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
self.