pub fn read_latest(
journals: &mut Vec<Journal>,
aim_path: &Path,
) -> Result<String>Expand description
Reads the contents of the latest version section of an AIM file based on its journal entries.
This function retrieves the content of the most recent complete version in an AIM file by using the journal entries to locate and read from the appropriate byte position. It reads from the start position of the latest journal entry to the end of the file.
§Arguments
journals- A mutable reference to a vector that will be populated with journal entries. This vector is cleared and populated with entries from the journal file.aim_path- The path to the AIM file from which to read the latest version content.
§Returns
Ok(String)- The content of the latest version section as a StringErr- An error if the file cannot be read, if there are no journal entries, or if there are UTF-8 conversion issues
§Errors
This function will return an error in the following cases:
- The AIM file cannot be opened or read
- The journal file cannot be loaded or parsed
- There are no journal entries in the file (empty journal)
- UTF-8 conversion fails when reading the file content
§Examples
use std::path::Path;
use aimx::aim::{Journal, journal_load, read_latest};
let mut journals = Vec::new();
let path = Path::new("workflow.aim");
// Read the latest version content
let latest_content = read_latest(&mut journals, path)?;
println!("Latest version content: {}", latest_content);