#[non_exhaustive]pub struct CommandJournal {
pub version: u32,
pub entries: Vec<JournalEntry>,
/* private fields */
}Available on crate features
state and storage only.Expand description
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.version: u32File format version. Currently 1.
entries: Vec<JournalEntry>The entries, oldest first.
Implementations§
Source§impl CommandJournal
impl CommandJournal
Sourcepub fn export_python(&self) -> String
pub fn export_python(&self) -> String
Export the journal as a Python replay script.
Sourcepub fn export_rust(&self) -> String
pub fn export_rust(&self) -> String
Export the journal as a Rust replay array.
Sourcepub fn append(&mut self, command: impl Into<CommandId>) -> &JournalEntry
pub fn append(&mut self, command: impl Into<CommandId>) -> &JournalEntry
Append a command with no arguments.
Sourcepub fn append_with(
&mut self,
command: impl Into<CommandId>,
args: Value,
label: impl Into<String>,
) -> &JournalEntry
pub fn append_with( &mut self, command: impl Into<CommandId>, args: Value, label: impl Into<String>, ) -> &JournalEntry
Append a command with arguments.
Sourcepub fn append_at(
&mut self,
timestamp: f64,
command: impl Into<CommandId>,
args: Option<Value>,
label: Option<String>,
) -> &JournalEntry
pub fn append_at( &mut self, timestamp: f64, command: impl Into<CommandId>, args: Option<Value>, label: Option<String>, ) -> &JournalEntry
Append a command with an explicit timestamp.
Sourcepub fn entries(&self) -> &[JournalEntry]
pub fn entries(&self) -> &[JournalEntry]
The entries.
Sourcepub fn last(&self) -> Option<&JournalEntry>
pub fn last(&self) -> Option<&JournalEntry>
The newest entry.
Sourcepub fn since(&self, sequence: u64) -> &[JournalEntry]
pub fn since(&self, sequence: u64) -> &[JournalEntry]
Entries with a sequence greater than sequence.
Sourcepub fn to_json(&self) -> Result<String, JournalError>
pub fn to_json(&self) -> Result<String, JournalError>
Serialize the journal as pretty JSON.
§Errors
When serialization fails (it does not for these types).
Sourcepub fn from_json(json: &str) -> Result<Self, JournalError>
pub fn from_json(json: &str) -> Result<Self, JournalError>
Parse a journal, rejecting a newer version.
§Errors
When the JSON is malformed or the version is newer than Self::VERSION.
Trait Implementations§
Source§impl Clone for CommandJournal
impl Clone for CommandJournal
Source§impl Debug for CommandJournal
impl Debug for CommandJournal
Source§impl Default for CommandJournal
impl Default for CommandJournal
Source§impl<'de> Deserialize<'de> for CommandJournal
impl<'de> Deserialize<'de> for CommandJournal
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for CommandJournal
impl PartialEq for CommandJournal
Source§impl Serialize for CommandJournal
impl Serialize for CommandJournal
impl StructuralPartialEq for CommandJournal
Auto Trait Implementations§
impl Forget for CommandJournal
impl Freeze for CommandJournal
impl Move for CommandJournal
impl RefUnwindSafe for CommandJournal
impl Send for CommandJournal
impl Sync for CommandJournal
impl Unpin for CommandJournal
impl UnsafeUnpin for CommandJournal
impl UnwindSafe for CommandJournal
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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