pub struct EpochConfig {
pub epoch_id: EpochId,
pub version: String,
pub tags: HashMap<String, EpochId>,
pub list_existing_epochs: HashMap<EpochId, Option<EpochInfo>>,
}Expand description
The file written to .epochconfig that tells the CLI which epoch folder is the “current” one.
Only the minimal information needed for fast switches is stored:
- the numeric identifier of the selected epoch,
- a list of human-readable tags,
- the absolute path to the epoch’s directory.
No world or event data lives here - it is purely a lightweight pointer.
Fields§
§epoch_id: EpochIdThe epoch ID that the binary should consider “current”.
version: StringThe version of the file loaded, and hopefully of all the project
Optional human-friendly tags (e.g. "winter-B", "post-war").
list_existing_epochs: HashMap<EpochId, Option<EpochInfo>>A hashmap containing the name of all existing epochs, only loaded in memory if used
Implementations§
Source§impl EpochConfig
impl EpochConfig
Sourcepub fn new_from_path(_path: Option<&Path>) -> Result<Self, EpochError>
pub fn new_from_path(_path: Option<&Path>) -> Result<Self, EpochError>
Create a new config from an existig path
Sourcepub fn try_load(&mut self, epoch_id: &EpochId) -> Result<(), EpochError>
pub fn try_load(&mut self, epoch_id: &EpochId) -> Result<(), EpochError>
Loads the metadata for an epoch from disk into the in-memory cache.
The epoch identified by epoch_id must exist in list_existing_epochs.
The JSON file on disk is read, deserialized into an EpochInfo, and
stored in the map. Any existing value for that epoch is overwritten.
§Returns
Ok(())when the epoch was successfully read and cached.Err(EpochError::EpochNotFound(..))if the epoch is not present in the internal map.Err(EpochError::Serde { .. })if the JSON file could not be parsed.Err(EpochError::Io { .. })if the file could not be read.
Sourcepub fn try_load_current(&mut self) -> Result<&EpochInfo, EpochError>
pub fn try_load_current(&mut self) -> Result<&EpochInfo, EpochError>
Load the currently active epoch.
This helper first ensures that the current epoch’s metadata is cached
by delegating to try_load, then returns a reference to it.
§Returns
Ok(&EpochInfo)- Reference to the cached epoch.- Propagates any error from
try_load.
Sourcepub unsafe fn try_load_id(
&self,
epoch_id: EpochId,
) -> Result<&EpochInfo, EpochError>
pub unsafe fn try_load_id( &self, epoch_id: EpochId, ) -> Result<&EpochInfo, EpochError>
Load an epoch by its identifier.
The caller must guarantee that the epoch has already been loaded into
the cache (e.g. by calling try_load). This function is marked unsafe
because it performs a raw reference conversion without performing that
check.
§Safety
Calling this function when the requested epoch has not yet been loaded results in undefined behaviour.
§Arguments
epoch_id- Identifier of the epoch to load.
§Returns
Ok(&EpochInfo)- Reference to the cached epoch.Err(EpochError::EpochHashingImpossible(..))- The identifier is unknown.Err(EpochError::LoadingEpochId(..))- The epoch data is not yet present in the cache.
Sourcepub fn try_load_current_as_mut(&mut self) -> Result<&mut EpochInfo, EpochError>
pub fn try_load_current_as_mut(&mut self) -> Result<&mut EpochInfo, EpochError>
Load the currently active epoch mutably.
This is a convenience wrapper that forwards to try_load_id_as_mut
for the current epoch.
§Returns
Ok(&mut EpochInfo)- Mutable reference to the cached epoch.- Propagates any error from the underlying load routine.
Sourcepub fn get_epoch_id(&self, id: &EpochIdentifier) -> Result<EpochId, EpochError>
pub fn get_epoch_id(&self, id: &EpochIdentifier) -> Result<EpochId, EpochError>
Retrieves the internal epoch ID for a given identifier.
The identifier can be either a tag string (EpochIdentifier::Tag) or an
explicit epoch ID (EpochIdentifier::Id).
- When a tag is supplied the function looks up the corresponding epoch ID in
the
tagsmap. - When an ID is supplied it verifies that an epoch with that ID exists in
list_existing_epochsand returns it.
§Returns
Ok(epoch_id)when the identifier is successfully resolved.Err(EpochError::AmbiguousTag(tag))if a supplied tag does not exist.Err(EpochError::EpochFolderMissing(id, path))if an ID does not have an associated epoch folder.
Sourcepub fn delete_id(&mut self, id: EpochId) -> Result<(), EpochError>
pub fn delete_id(&mut self, id: EpochId) -> Result<(), EpochError>
Delete an entire epoch folder by its ID.
The function removes the directory, deletes all references to the
epoch from list_existing_epochs and tags, and then writes the
updated configuration to disk.
Sourcepub fn compute_next(&mut self) -> Result<EpochInfo, EpochError>
pub fn compute_next(&mut self) -> Result<EpochInfo, EpochError>
Compute the next epoch.
Currently this function is a placeholder that creates a new epoch
with the ID immediately following the current one. The actual logic
is deferred to the EpochInfo -> World subsystem.
Sourcepub unsafe fn update_all_temporary_values(&mut self)
pub unsafe fn update_all_temporary_values(&mut self)
Update all temporary values of every entity in the current epoch.
§Safety
- The caller must guarantee that the current epoch is loaded and its storage is still valid for the duration of the call.
- The function performs raw pointer arithmetic /
unsafereads/writes on the internal data structures. No other thread may be mutably borrowing the same data at the same time.
Sourcepub unsafe fn reset_temporary_stats(&mut self) -> Result<(), EpochError>
pub unsafe fn reset_temporary_stats(&mut self) -> Result<(), EpochError>
Reset all temporary values to the current live values.
§Safety
- The caller must ensure that the current epoch is loaded and that no other mutable references to the same data exist.
- This method writes directly into the entity structs; any concurrent access will lead to undefined behaviour.
Sourcepub unsafe fn update_temps(&mut self)
pub unsafe fn update_temps(&mut self)
Update temporary values for every entity assuming the current epoch is loaded.
§Safety
- Same as
update_all_temporary_values: the current epoch must be loaded and no other mutable references may exist.
Sourcepub fn insert_and_save(
&mut self,
new_epoch: EpochInfo,
save_mode: &SaveMode,
) -> Result<(), EpochError>
pub fn insert_and_save( &mut self, new_epoch: EpochInfo, save_mode: &SaveMode, ) -> Result<(), EpochError>
Insert a new epoch into the configuration and persist it.
The function creates the epoch’s directory, writes its metadata, updates the internal maps, and finally writes the updated configuration to disk.
§Returns
Ok(())- the epoch was added and the configuration was saved.Err(EpochError::EpochAlreadyExists(..))if an epoch with the same ID already exists.
Sourcepub fn log_elements(&mut self, list_ids: &[EpochId]) -> Result<(), EpochError>
pub fn log_elements(&mut self, list_ids: &[EpochId]) -> Result<(), EpochError>
Load and display the metadata for a list of epoch IDs.
The function first ensures that each requested epoch’s metadata is loaded into memory, then displays a formatted log for each one.
Trait Implementations§
Source§impl Clone for EpochConfig
impl Clone for EpochConfig
Source§fn clone(&self) -> EpochConfig
fn clone(&self) -> EpochConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ConfigWritable for EpochConfig
impl ConfigWritable for EpochConfig
Source§fn save_folder(&self) -> String
fn save_folder(&self) -> String
Source§fn as_json(&self, action: String) -> Result<String, EpochError>
fn as_json(&self, action: String) -> Result<String, EpochError>
Source§fn save_with_context(
&self,
action_description: &str,
do_not_erase: &SaveMode,
) -> Result<(), EpochError>
fn save_with_context( &self, action_description: &str, do_not_erase: &SaveMode, ) -> Result<(), EpochError>
Source§impl Debug for EpochConfig
impl Debug for EpochConfig
Source§impl Default for EpochConfig
impl Default for EpochConfig
Source§impl<'de> Deserialize<'de> for EpochConfig
impl<'de> Deserialize<'de> for EpochConfig
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>,
Auto Trait Implementations§
impl Freeze for EpochConfig
impl RefUnwindSafe for EpochConfig
impl Send for EpochConfig
impl Sync for EpochConfig
impl Unpin for EpochConfig
impl UnwindSafe for EpochConfig
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,
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more