EpochConfig

Struct EpochConfig 

Source
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: EpochId

The epoch ID that the binary should consider “current”.

§version: String

The version of the file loaded, and hopefully of all the project

§tags: HashMap<String, EpochId>

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

Source

pub fn new_from_path(_path: Option<&Path>) -> Result<Self, EpochError>

Create a new config from an existig path

Source

pub fn version(&self) -> String

Output the current version vs the filesystem version

Source

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.
Source

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.
Source

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.
Source

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.
Source

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 tags map.
  • When an ID is supplied it verifies that an epoch with that ID exists in list_existing_epochs and 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.
Source

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.

Source

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.

Source

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 / unsafe reads/writes on the internal data structures. No other thread may be mutably borrowing the same data at the same time.
Source

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.
Source

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.
Source

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.
Source

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

Source§

fn clone(&self) -> EpochConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ConfigWritable for EpochConfig

Source§

fn save_path(&self) -> String

The full path indicating where to save the config
Source§

fn save_folder(&self) -> String

The folder where to save the file to save the config
Source§

fn as_json(&self, action: String) -> Result<String, EpochError>

Serialises the config into a pretty JSON string. Read more
Source§

fn save_with_context( &self, action_description: &str, do_not_erase: &SaveMode, ) -> Result<(), EpochError>

Saves the config into its nominal path. Read more
Source§

impl Debug for EpochConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EpochConfig

Source§

fn default() -> Self

Create an empty config, mainly for initialisation

Source§

impl<'de> Deserialize<'de> for EpochConfig

Source§

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 Serialize for EpochConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
Source§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
Source§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
Source§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
Source§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
Source§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
Source§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
Source§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
Source§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
Source§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
Source§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
Source§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
Source§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
Source§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
Source§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
Source§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
Source§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
Source§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
Source§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,