Skip to main content

SessionState

Struct SessionState 

Source
pub struct SessionState {
Show 15 fields session: Arc<Session>, supported_games: SupportedGames, game: GameInfo, schema: Option<Schema>, first_game_change_done: bool, packs: BTreeMap<String, Pack>, pack_modes: BTreeMap<String, OperationalMode>, dependencies: Dependencies, dependencies_error: Option<String>, changed_packs: BTreeSet<String>, autosave_thread: Option<JoinHandle<()>>, search: Option<GlobalSearch>, pending_startpos: Option<PendingStartpos>, diagnostics: Option<DiagnosticsResults>, lua_api_cache: Option<(PathBuf, u64, Option<LuaApi>)>,
}
Expand description

Everything a session owns. One instance lives in each session’s background loop.

Fields§

§session: Arc<Session>

The session this state belongs to. Used to keep its list of open pack names in sync.

§supported_games: SupportedGames

Registry of every game RPFM supports.

§game: GameInfo

The game currently selected.

§schema: Option<Schema>

Schema of the selected game, if it could be loaded.

§first_game_change_done: bool

If the game has already been selected once, so the first selection always rebuilds everything.

§packs: BTreeMap<String, Pack>

All open packs, by key.

Each pack’s disk_file_path is either its absolute path on disk, or only its file name if it’s not saved there.

§pack_modes: BTreeMap<String, OperationalMode>

Operational mode (Normal or MyMod) of each open pack, keyed by the same pack key as packs.

§dependencies: Dependencies

Vanilla and parent files of the selected game.

§dependencies_error: Option<String>

Why the dependencies couldn’t be fully loaded the last time they were, if they couldn’t.

§changed_packs: BTreeSet<String>

Keys of the packs changed since their last autosave.

§autosave_thread: Option<JoinHandle<()>>

Thread writing the last autosave, if it may still be running. Saves wait for it, so they don’t replace packs it’s reading.

§search: Option<GlobalSearch>

The last search, with its matches, if any.

§pending_startpos: Option<PendingStartpos>

Startpos build started and not yet finished, if any.

§diagnostics: Option<DiagnosticsResults>

Results of the last diagnostics check, if any.

§lua_api_cache: Option<(PathBuf, u64, Option<LuaApi>)>

Lua scripting API of the selected game, built on first use. See cached_lua_api.

Implementations§

Source§

impl SessionState

Source

pub fn set_game_selected( &mut self, game_key: &str, rebuild_dependencies: bool, settings: &Settings, disable_uuid_regeneration: bool, ) -> Result<(CompressionFormat, Option<DependenciesInfo>)>

Changes the selected game, loading its schema and adapting the open packs to it.

If the dependencies are rebuilt, their tables are left undecoded: call Self::decode_dependency_tables after this.

§Arguments
  • game_key - Key of the game to select.
  • rebuild_dependencies - If the dependencies are rebuilt for the new game.
  • settings - Settings, to find the game’s install folder.
  • disable_uuid_regeneration - If tables keep their GUID when re-encoded for the new schema.
§Returns

The compression format of the first open pack, and the info of the dependencies if they were rebuilt.

Source

pub fn decode_dependency_tables(&mut self)

Decodes the tables of the dependencies with the loaded schema.

Source

pub fn generate_dependencies_cache( &mut self, settings: &Settings, ignore_game_files_in_ak: bool, ) -> Result<DependenciesInfo>

Generates the dependencies cache of the selected game from its files and Assembly Kit, then loads it.

§Arguments
  • settings - Settings, to find the game’s install folder and Assembly Kit.
  • ignore_game_files_in_ak - If tables in the game files are skipped when reading the Assembly Kit.
§Returns

The info of the new dependencies.

Source

pub fn rebuild_dependencies( &mut self, only_parent_packs: bool, settings: &Settings, ) -> Result<DependenciesInfo>

Rebuilds the dependencies of the selected game.

§Arguments
  • only_parent_packs - If only the parent packs are reloaded, instead of the whole dependencies.
  • settings - Settings, to find the game’s install folder.
§Returns

The info of the rebuilt dependencies.

Source

pub fn rebuild_dependencies_after_schema_update( &mut self, settings: &Settings, ) -> Result<()>

Rebuilds the dependencies after the schema changed, if the vanilla data is loaded.

§Arguments
  • settings - Settings, to find the game’s install folder.
Source

fn load_dependencies( &mut self, cache_path: Option<&Path>, decode_tables: bool, settings: &Settings, ) -> Result<()>

Rebuilds the dependencies of the selected game, keeping the error for the session status if it fails.

§Arguments
  • cache_path - Path of the dependencies cache to load, or None to only reload the loose and parent files.
  • decode_tables - If the tables are decoded with the loaded schema.
  • settings - Settings, to find the game’s install folder.
§Errors

If any part of the dependencies couldn’t be loaded. The parts that could are kept loaded.

Source

pub fn dependencies_info(&self) -> DependenciesInfo

Returns the files of the dependencies of the selected game.

Source§

impl SessionState

Source

pub fn check_diagnostics( &mut self, diagnostics: Diagnostics, paths_to_check: &[ContainerPath], check_ak_only_refs: bool, settings: &Settings, on_progress: &(dyn Fn(usize, usize) -> bool + Sync), ) -> Option<Diagnostics>

Checks the open packs for problems.

Does nothing if there is no schema.

§Arguments
  • diagnostics - Results of a previous check, or a new one with the diagnostics to ignore.
  • paths_to_check - Paths to recheck, keeping the previous results for the rest. If empty, everything is checked.
  • check_ak_only_refs - If references to tables only in the Assembly Kit are checked.
  • settings - Settings, to find the game’s install folder and Assembly Kit.
  • on_progress - Called with the steps done and their total as the check advances. If it returns false, the check stops early.
§Returns

The updated diagnostics, or None if the check was stopped.

Source

pub fn run_diagnostics( &mut self, request: &RunDiagnostics, settings: &Settings, on_progress: &(dyn Fn(usize, usize) -> bool + Sync), ) -> Option<DiagnosticsSummary>

Checks the open packs for problems, keeping the results for Self::list_diagnostics.

§Arguments
  • request - What to check.
  • settings - Settings, to find the game’s install folder and Assembly Kit.
  • on_progress - Called with the steps done and their total as the check advances. If it returns false, the check stops early.
§Returns

A summary of the results, or None if the check was stopped, keeping the results of the last check.

Source

pub fn list_diagnostics( &self, request: &ListDiagnostics, ) -> Result<DiagnosticList>

Returns a page of the results of the last diagnostics check matching the request.

§Errors

Fails if there are no results yet.

Source

pub fn diagnostics_report(&self) -> Result<Diagnostics>

Returns the results of the last diagnostics check, as the check returns them.

§Errors

Fails if there are no results yet.

Source

pub fn ignore_diagnostics( &mut self, request: &IgnoreDiagnostics, ) -> Result<Done>

Makes the next diagnostics checks of a pack skip some results, saving the rule in the pack’s settings.

§Errors

Fails if the pack isn’t open, or if any value has characters the rule format uses as separators.

Source

pub fn lua_hovers( &mut self, source: &str, settings: &Settings, ) -> Vec<(u64, u64, u64, u64, String)>

Returns the hovers of a Lua script, with the docs of the game’s Lua API. Empty if the API is not available.

Source

pub fn lua_run_tests( &mut self, test_source: &str, campaign: Option<String>, settings: &Settings, ) -> Result<LuaTestReport>

Runs Lua tests against the scripts of the game and the open packs, outside of the game.

§Arguments
  • test_source - Code of the Lua test file.
  • campaign - Campaign whose vanilla scripts to load. If None, only the script libraries and the mods are loaded.
  • settings - Settings, to find the game’s Assembly Kit.
§Returns

The results of the tests.

§Errors

Fails if the game’s Lua API is not available, or if the tests can’t be loaded.

Source§

impl SessionState

Source

pub fn new_file( &mut self, pack_key: &str, path: &str, new_file: NewFile, ) -> Result<()>

Creates a new file in a pack.

§Arguments
  • pack_key - Key of the pack to create the file in.
  • path - Path of the new file in the pack.
  • new_file - Type and initial data of the new file.
§Errors

Fails if the file is a table with no definition in the schema, or if it can’t be inserted.

Source

pub fn list_files(&self, request: &ListFiles) -> Result<FileList>

Returns a page of the files of a source matching the request, sorted by path.

Source

pub fn add_files_from_disk( &mut self, pack_key: &str, source_paths: &[PathBuf], destination_paths: &[ContainerPath], paths_to_ignore: &Option<Vec<PathBuf>>, include_base_folder: bool, ) -> Result<(Vec<ContainerPath>, Option<String>)>

Adds files and folders from disk to a pack.

§Arguments
  • pack_key - Key of the pack to add the files to.
  • source_paths - Paths on disk of the files and folders to add.
  • destination_paths - Path in the pack of each source path.
  • paths_to_ignore - Source paths under any of these are skipped.
  • include_base_folder - If added folders keep their own name in the pack, or only their contents are added.
§Returns

The paths added, and the last error found while adding them, if any.

Source

pub fn add_files_from_pack( &mut self, target_key: &str, source_key: &str, paths: &[ContainerPath], ) -> Result<(Vec<ContainerPath>, Vec<String>, Option<String>)>

Copies files from one open pack to another.

§Arguments
  • target_key - Key of the pack to copy the files to.
  • source_key - Key of the pack to copy the files from.
  • paths - Paths of the files and folders to copy.
§Returns

The paths added to the target pack, the paths of the files that couldn’t be read, and the last error reading them.

Source

pub fn add_files_to_animpack( &mut self, source_pack_key: &str, anim_pack_key: &str, anim_pack_path: &str, paths: &[ContainerPath], ) -> Result<(Vec<ContainerPath>, Vec<String>, Option<String>)>

Copies files from an open pack into an AnimPack of another (or the same) open pack.

§Arguments
  • source_pack_key - Key of the pack to copy the files from.
  • anim_pack_key - Key of the pack containing the AnimPack.
  • anim_pack_path - Path of the AnimPack in its pack.
  • paths - Paths of the files and folders to copy.
§Returns

The paths added to the AnimPack, the paths of the files that couldn’t be read, and the last error reading them.

Source

pub fn add_files_from_animpack( &mut self, anim_pack_key: &str, dest_pack_key: &str, data_source: DataSource, anim_pack_path: &str, paths: &[ContainerPath], ) -> Result<Vec<ContainerPath>>

Copies files from an AnimPack into an open pack.

§Arguments
  • anim_pack_key - Key of the pack containing the AnimPack. Only used if data_source is a pack.
  • dest_pack_key - Key of the pack to copy the files to.
  • data_source - Where the AnimPack is.
  • anim_pack_path - Path of the AnimPack in its source.
  • paths - Paths in the AnimPack of the files and folders to copy.
§Returns

The paths of the copied files.

Source

pub fn delete_from_animpack( &mut self, pack_key: &str, anim_pack_path: &str, paths: &[ContainerPath], ) -> Result<()>

Deletes files from an AnimPack in an open pack.

Source

pub fn view_data( &mut self, file: &FileRef, enable_esf_editor: bool, ) -> Result<ViewData>

Decodes a file as a client opening it in a view needs it.

§Arguments
  • file - The file.
  • enable_esf_editor - If ESF files are decoded.
Source

pub fn decode_file( &mut self, pack_key: &str, path: &str, data_source: DataSource, enable_esf_editor: bool, ) -> Result<DecodedFile>

Decodes a file.

§Arguments
  • pack_key - Key of the pack containing the file. Only used if data_source is a pack.
  • path - Path of the file in its source.
  • data_source - Where the file is.
  • enable_esf_editor - If ESF files are decoded.
§Returns

The decoded file, or why it wasn’t decoded.

Source

pub fn save_file_from_view( &mut self, pack_key: &str, path: &str, decoded: RFileDecoded, ) -> Result<()>

Replaces the data of a file of a pack with its edited version.

Source

pub fn delete_files( &mut self, pack_key: &str, paths: &[ContainerPath], ) -> Result<Vec<ContainerPath>>

Deletes files and folders from a pack.

§Returns

The paths deleted.

Source

pub fn paste_files(&mut self, request: &PasteFiles) -> Result<FilesPasted>

Copies or moves files and folders of open packs into a folder of an open pack. Cut files are removed from their packs before pasting, so they can be pasted where they were.

§Returns

The paths added to the target pack, and the paths removed from each source pack if the files were cut.

Source

pub fn duplicate_files( &mut self, pack_key: &str, paths: &[ContainerPath], ) -> Result<Vec<ContainerPath>>

Duplicates files in the same pack, adding a numeric suffix to their names.

§Returns

The paths of the duplicates.

Source

pub fn extract_files( &mut self, pack_key: &str, paths_by_source: &BTreeMap<DataSource, Vec<ContainerPath>>, destination: &Path, as_tsv: bool, options: ExtractOptions, ) -> Result<Vec<PathBuf>>

Extracts files from a pack or from the dependencies to disk.

§Arguments
  • pack_key - Key of the pack to extract from. Only used for paths from a pack.
  • paths_by_source - Paths to extract, by source. If there are paths from a pack, only those are extracted.
  • destination - Folder to extract the files to.
  • as_tsv - If tables are extracted as TSV.
  • options - Options for writing the files.
§Returns

The paths on disk of the extracted files.

§Errors

Fails if any file couldn’t be extracted.

Source

pub fn rename_files( &mut self, pack_key: &str, renames: &[(ContainerPath, ContainerPath)], ) -> Result<Vec<(ContainerPath, ContainerPath)>>

Renames or moves files and folders in a pack.

§Returns

The old and new path of each moved file.

Source

pub fn file_exists(&self, pack_key: &str, path: &str) -> Result<bool>

Returns if a file exists in a pack.

Source

pub fn open_in_external_program( &mut self, pack_key: &str, path: &str, options: ExtractOptions, ) -> Result<PathBuf>

Extracts a file of a pack to a temp folder and opens it in the system’s default program for its type.

§Returns

The path of the extracted file.

§Errors

Fails if the pack isn’t open, or if the file can’t be extracted.

Source

pub fn save_file_from_external( &mut self, pack_key: &str, path: &str, external_path: &Path, ) -> Result<()>

Replaces a file of a pack with the data of a file on disk, edited by an external program.

Source

pub fn save_files_and_optimize( &mut self, pack_key: &str, files: Vec<RFile>, optimizer_options: Option<OptimizerOptions>, ) -> Result<FilesChanged>

Adds files edited by the client to a pack, replacing existing ones, and optionally optimizes the pack.

§Arguments
  • pack_key - Key of the pack to add the files to.
  • files - Files to add, already named with their path in the pack.
  • optimizer_options - If set, the pack is optimized with these options after adding the files.
§Returns

The paths added, and the paths deleted by the optimizer.

Source

pub fn set_video_format( &mut self, pack_key: &str, path: &str, format: SupportedFormats, ) -> Result<()>

Changes the format of a ca_vp8 video of a pack.

Source

pub fn files_from_all_sources( &self, paths: &[ContainerPath], lowercase_paths: bool, ) -> HashMap<DataSource, HashMap<String, RFile>>

Returns the files at the provided paths from the open packs, the parent packs and the game files.

§Arguments
  • paths - Paths of the files and folders to get.
  • lowercase_paths - If the returned paths are lowercased.
§Returns

The files found, by source and path.

Source

pub fn anim_paths_by_skeleton(&mut self, skeleton_name: &str) -> HashSet<String>

Returns the paths of the animations using a skeleton, from the open packs, the parent packs and the game files.

Source

pub fn import_dependencies( &mut self, pack_key: &str, paths_by_source: &BTreeMap<DataSource, Vec<ContainerPath>>, ) -> Result<(Vec<ContainerPath>, Vec<String>, Option<String>)>

Copies files from the dependencies (game files, parent packs or Assembly Kit tables) into a pack.

§Arguments
  • pack_key - Key of the pack to copy the files into.
  • paths_by_source - Paths of the files and folders to copy, by source.
§Returns

The paths added, the paths that couldn’t be added, and the last error found reading them.

Source§

impl SessionState

Source

pub fn create_file(&mut self, request: &CreateFile) -> Result<FileEntry>

Creates a new empty file in an open pack.

§Returns

The path and type of the new file.

Source

pub fn add_disk_files( &mut self, request: &AddFilesFromDisk, include_base_folder: bool, ) -> Result<FilesAdded>

Adds files and folders from disk to an open pack, under a folder of the pack.

§Arguments
  • request - What to add, and where.
  • include_base_folder - If added folders keep their own name in the pack.
Source

pub fn copy_files_to_pack(&mut self, request: &CopyFiles) -> Result<FilesAdded>

Copies files and folders from any source into an open pack, keeping their paths.

Assembly Kit tables get the file name tables have in the game files.

Source

pub fn delete_paths(&mut self, request: &DeleteFiles) -> Result<FilesDeleted>

Deletes files and folders from an open pack.

Source

pub fn rename_paths(&mut self, request: &RenameFiles) -> Result<FilesRenamed>

Renames or moves files and folders of an open pack.

Source

pub fn duplicate_paths( &mut self, request: &DuplicateFiles, ) -> Result<FilesAdded>

Duplicates files of an open pack in the same pack.

Source

pub fn extract_paths( &mut self, request: &ExtractFiles, options: ExtractOptions, ) -> Result<FilesExtracted>

Extracts files and folders of an open pack, the game files or the parent packs to disk.

§Arguments
  • request - What to extract, and where.
  • options - Options for writing the files.
Source

pub fn read_file( &mut self, request: &ReadFile, enable_esf_editor: bool, disable_uuid_regeneration: bool, ) -> Result<FileContents>

Returns the contents of a file of any source.

§Arguments
  • request - The file, and how to return it.
  • enable_esf_editor - If ESF files are decoded.
  • disable_uuid_regeneration - If tables keep their GUID when encoded to return their bytes.
§Errors

Fails if the file doesn’t exist, or can’t be returned in the requested format.

Source

pub fn write_file(&mut self, request: &WriteFile) -> Result<()>

Replaces the contents of a file of an open pack.

With raw contents, the file is created if it doesn’t exist.

§Errors

Fails if the file doesn’t exist (except for raw contents), or if the contents don’t fit the file.

Source

pub fn list_animpack(&mut self, file: &FileRef) -> Result<FileList>

Returns the files inside an AnimPack of any source, sorted by path.

Source

pub fn add_to_animpack(&mut self, request: &AddToAnimPack) -> Result<FilesAdded>

Copies files of an open pack into an AnimPack of an open pack.

Source

pub fn extract_from_animpack( &mut self, request: &ExtractFromAnimPack, ) -> Result<FilesAdded>

Copies files of an AnimPack of any source into an open pack.

Source

pub fn delete_in_animpack(&mut self, request: &DeleteFromAnimPack) -> Result<()>

Deletes files from an AnimPack of an open pack.

Source

fn animpack_container_paths( &mut self, file: &FileRef, paths: &[String], ) -> Result<Vec<ContainerPath>>

Resolves paths inside an AnimPack into file or folder paths, depending on if there’s a file at each one.

Source

pub(super) fn check_file_exists(&self, file: &FileRef) -> Result<()>

Resolves paths of an open pack into file or folder paths, depending on if there’s a file at each one. Checks that a file exists in its source.

§Errors

Fails if the pack of the file isn’t open, or if the file doesn’t exist. If its path is a folder of the source, the error says so, with the files in it.

Source

pub(super) fn pack_container_paths( &self, pack_key: &str, paths: &[String], ) -> Result<Vec<ContainerPath>>

Source§

impl SessionState

Source

pub fn new_pack( &mut self, name: Option<&str>, settings: &Settings, ) -> Result<String>

Creates a new empty pack.

§Arguments
  • name - File name of the pack. If None, a free new_pack.pack-like name is used.
  • settings - Settings, to find the game’s install folder.
§Returns

The key of the new pack.

§Errors

Fails if the name is not a file name ending in .pack.

Source

pub fn open_packs( &mut self, paths: &[PathBuf], lazy_loading: bool, ) -> Result<(String, ContainerInfo)>

Opens one or more packs, merged into a single one.

§Arguments
  • paths - Paths of the packs to open. If there are more than one, the merged pack has no path, and is named after the first one.
  • lazy_loading - If file data should be read from disk only when needed.
§Returns

The key and info of the opened pack.

§Errors

Fails if any of the packs is already open, or if any of them can’t be read.

Source

pub fn open_ca_packs( &mut self, settings: &Settings, ) -> Result<(String, ContainerInfo)>

Opens all the CA packs of the selected game, merged into a single one.

§Arguments
  • settings - Settings, to find the game’s install folder.
§Returns

The key and info of the opened pack.

§Errors

Fails if they’re already open, or if they can’t be read.

Source

pub fn close_pack(&mut self, pack_key: &str) -> Result<()>

Closes a pack without saving it.

Source

pub fn close_all_packs(&mut self)

Closes all open packs without saving them.

Source

pub fn save_pack( &mut self, pack_key: &str, path: Option<&Path>, options: SaveOptions, ) -> Result<ContainerInfo>

Saves a pack to disk.

§Arguments
  • pack_key - Key of the pack to save.
  • path - Absolute path to save the pack to, creating its missing folders. If None, the pack is saved to its current path.
  • options - How to save the pack.
§Returns

The info of the saved pack.

§Errors

Fails if the pack is of a CA type and editing them is not allowed, if it has no path on disk yet, if the new path is not absolute, or if saving fails.

Source

pub fn update_pack(&mut self, request: &UpdatePack) -> Result<PackDetails>

Changes properties of a pack. Only the properties set in the request are changed.

§Errors

Fails, without changing anything, if the request enables encryption on a pack whose version doesn’t support it.

Source

pub fn pack_summary(&self, pack_key: &str) -> Result<PackSummary>

Returns the short description of an open pack.

Source

pub fn files_info(&self, request: &GetFilesInfo) -> Result<FilesInfo>

Returns the info of files of a pack: the ones at the requested paths, or all of them.

Source

pub fn pack_details(&self, pack_key: &str) -> Result<PackDetails>

Returns the details of an open pack.

Source

pub fn pack_path(&self, pack_key: &str) -> Result<PathBuf>

Returns the path of a pack on disk.

Source

pub fn pack_name(&self, pack_key: &str) -> Result<String>

Returns the file name of a pack.

Source

pub fn set_compression_format( &mut self, pack_key: &str, compression_format: CompressionFormat, ) -> Result<CompressionFormat>

Changes the compression format of a pack.

§Returns

The format actually set, which may differ from the requested one if the game doesn’t support it.

Source

pub fn pack_settings(&self, pack_key: &str) -> Result<PackSettings>

Returns the settings of a pack.

Source

pub fn add_pack_ignored_diagnostics_line( &mut self, pack_key: &str, line: String, ) -> Result<()>

Appends a line to the list of files a pack ignores in the diagnostics.

Source

pub fn pack_operational_mode(&self, pack_key: &str) -> OperationalMode

Returns the operational mode of a pack. Unknown packs are in normal mode.

Source

pub fn pack_settings_values(&self, pack_key: &str) -> Result<PackSettingsValues>

Returns the settings of a pack.

Source

pub fn update_pack_settings( &mut self, request: &UpdatePackSettings, ) -> Result<PackSettingsValues>

Changes settings of a pack. Only the keys set in the request are changed.

§Returns

All the settings of the pack after the change.

Source

pub fn note_entries(&self, pack_key: &str, path: &str) -> Result<Vec<NoteEntry>>

Returns the notes of a pack for a path, with the notes of the folders containing it, as API entries.

If the path is empty, all the notes of the pack are returned.

Source

pub fn add_note_entry(&mut self, request: &AddNote) -> Result<NoteEntry>

Attaches a note to a file or folder of a pack.

§Returns

The added note, with its ID.

Source

pub fn notes_for_path(&self, pack_key: &str, path: &str) -> Result<Vec<Note>>

Returns the notes of a pack under a path.

Source

pub fn add_note( &mut self, pack_key: &str, note: Note, replace: bool, ) -> Result<Note>

Adds a note to a pack.

§Returns

The added note, with its ID assigned.

Source

pub fn delete_note(&mut self, pack_key: &str, path: &str, id: u64) -> Result<()>

Deletes a note from a pack.

Source

pub fn mark_packs_changed(&mut self, pack_key: Option<&str>)

Marks packs as changed since their last autosave.

§Arguments
  • pack_key - Key of the changed pack, or None if any open pack may have changed.
Source

pub fn autosave(&mut self, settings: &Settings)

Saves a backup copy of each pack changed since its last autosave in the autosave folder, keeping the newest ones.

The packs are copied here, but saved from another thread, so the session can keep running requests meanwhile. Vanilla packs, packs with autosaves disabled and packs that are neither mods nor movies are skipped.

§Arguments
  • settings - Settings, for the game’s install folder, the amount of autosaves to keep, and how to encode tables.
Source

fn autosave_to(&mut self, settings: &Settings, autosave_path: PathBuf)

Same as Self::autosave, but saving the backups in autosave_path.

If the previous autosave is still running, this does nothing, and the changed packs are left for the next one.

Source

pub fn wait_for_autosave(&mut self)

Waits until the running autosave, if any, finishes.

Autosaves read lazy-loaded files from the packs on disk, so this must be called before replacing any of them.

Source

pub fn missing_definitions( &mut self, pack_key: &str, ) -> Result<MissingDefinitions>

Returns the tables of a pack with rows that can’t be decoded with the schema, sorted by path.

This is slow, and only useful when a new patch lands and you want to know what tables need decoding.

Source

pub fn live_export( &mut self, pack_key: &str, settings: &Settings, disable_uuid_regeneration: bool, tsv_keys_first: bool, ) -> Result<()>

Exports the files of a pack to the game’s data folder, so they can be tested without saving the pack.

§Arguments
  • pack_key - Key of the pack to export.
  • settings - Settings, to find the game’s install folder.
  • disable_uuid_regeneration - If tables keep their GUID when encoded.
  • tsv_keys_first - If exported TSV files use the old column order, with keys first.
Source

fn insert_pack(&mut self, pack: Pack) -> String

Adds a pack to the open ones, in normal mode.

§Returns

The key of the pack.

Source§

impl SessionState

Source

pub fn update_schema_from_asskit( &mut self, settings: &Settings, ignore_game_files_in_ak: bool, disable_uuid_regeneration: bool, ) -> Result<()>

Updates the schema of the selected game with the table definitions of its Assembly Kit, and saves it.

§Arguments
  • settings - Settings, to find the game’s Assembly Kit.
  • ignore_game_files_in_ak - If tables in the game files are skipped.
  • disable_uuid_regeneration - If tables keep their GUID when re-encoded to reload the schema.
Source

pub fn reload_schema(&mut self, disable_uuid_regeneration: bool)

Reloads the schema of the selected game from disk, re-decoding the tables of the open packs.

§Arguments
  • disable_uuid_regeneration - If tables keep their GUID when re-encoded.
Source

pub fn save_schema(&mut self, schema: Schema) -> Result<()>

Saves a schema to disk as the schema of the selected game, and loads it.

Source

pub fn save_local_schema_patches( &self, patches: &HashMap<String, DefinitionPatch>, ) -> Result<()>

Saves local patches for the schema of the selected game.

Source

pub fn remove_local_schema_patches_for_table( &self, table_name: &str, ) -> Result<()>

Removes the local schema patches of a table.

Source

pub fn remove_local_schema_patches_for_table_and_field( &self, table_name: &str, field_name: &str, ) -> Result<()>

Removes the local schema patches of a field of a table.

Source

pub fn import_schema_patches( &mut self, patches: &HashMap<String, DefinitionPatch>, ) -> Result<()>

Adds patches to the schema of the selected game, and saves it.

Source

pub fn custom_table_names(&self) -> Result<Vec<String>>

Returns the names of the startpos and twad tables in the schema.

Source

pub fn table_definition( &self, request: &GetTableDefinition, ) -> Result<TableDefinition>

Returns the columns of a table as defined in the schema.

If the request has no version, the version of the table in the game files is used, or the newest one if there is none.

Source

pub fn schema_tables(&self, prefix: &str) -> Result<SchemaTables>

Returns the tables of the schema whose name starts with a prefix, with the versions they have definitions for.

Source

pub fn patch_column( &mut self, request: &PatchColumn, disable_uuid_regeneration: bool, ) -> Result<()>

Saves a local patch for a column of a table, and reloads the schema so it applies.

§Arguments
  • request - The patch.
  • disable_uuid_regeneration - If tables keep their GUID when re-encoded to reload the schema.
§Errors

Fails if a key of the patch is not a valid one, or if the patch can’t be saved.

Source

pub fn remove_patches( &mut self, request: &RemovePatches, disable_uuid_regeneration: bool, ) -> Result<()>

Removes the local patches of a table, or of one of its columns, and reloads the schema.

§Arguments
  • request - Patches to remove.
  • disable_uuid_regeneration - If tables keep their GUID when re-encoded to reload the schema.
Source

pub fn raw_definitions( &self, table_name: &str, version: Option<i32>, ) -> Result<RawDefinitions>

Returns the definitions of a table as the schema stores them, newest first.

Source

pub fn set_definition( &mut self, request: &SetDefinition, disable_uuid_regeneration: bool, ) -> Result<()>

Adds a definition to the schema, or replaces the one with its version, then saves and reloads the schema.

§Arguments
  • request - The definition.
  • disable_uuid_regeneration - If tables keep their GUID when re-encoded to reload the schema.
Source

pub fn delete_definition_and_save( &mut self, request: &DeleteDefinition, disable_uuid_regeneration: bool, ) -> Result<()>

Removes a definition from the schema, then saves and reloads the schema.

§Arguments
  • request - The definition to remove.
  • disable_uuid_regeneration - If tables keep their GUID when re-encoded to reload the schema.
Source

pub fn referencing_columns_of( &self, request: &GetReferencingColumns, ) -> Result<ReferencingColumns>

Returns the columns of other tables referencing each column of a table.

Source

pub fn import_patches( &mut self, request: &ImportPatches, disable_uuid_regeneration: bool, ) -> Result<()>

Adds patches to the schema itself, saves it, and reloads it.

§Arguments
  • request - The patches.
  • disable_uuid_regeneration - If tables keep their GUID when re-encoded to reload the schema.
Source

pub fn definitions_by_table_name( &self, table_name: &str, ) -> Result<Vec<Definition>>

Returns all the definitions of a table. Empty if the table is not in the schema.

Source

pub fn definition_patches( &self, table_name: &str, version: i32, ) -> Result<DefinitionPatch>

Returns the patches of a definition of a table, or of the table if the definition doesn’t exist.

Source

pub fn table_patches(&self, request: &GetTablePatches) -> Result<TablePatches>

Returns the patches of a definition of a table, by column name.

Source

pub fn referencing_columns( &self, table_name: &str, definition: &Definition, ) -> Result<HashMap<String, HashMap<String, Vec<String>>>>

Returns the columns of other tables referencing a table, by table name and column name.

Source§

impl SessionState

Source

fn global_search_replace( &mut self, search: GlobalSearch, matches: &[MatchHolder], ) -> Result<(GlobalSearch, Vec<RFileInfo>)>

Replaces matches of a global search.

§Arguments
  • search - The search the matches come from.
  • matches - Matches to replace.
§Returns

The search, and the info of the edited files.

Searches text, keeping the matches for Self::list_search_matches.

§Returns

A summary of the matches.

Source

pub fn list_search_matches( &self, request: &ListSearchMatches, ) -> Result<SearchMatchList>

Returns a page of the matches of the last search matching the request.

§Errors

Fails if there hasn’t been a search yet.

Source

pub fn replace_search_matches( &mut self, request: &ReplaceSearchMatches, ) -> Result<SearchReplaced>

Replaces matches of the last search, and searches the edited files again.

§Errors

Fails if there hasn’t been a search yet, if an ID doesn’t exist, or if replacing fails.

Source

pub fn search_report(&self) -> Result<SearchReport>

Returns the last search with all its matches, and the ID of the first match of each file.

§Errors

Fails if there is no search yet.

Source

fn files_info_in_all_packs(&self, paths: &[ContainerPath]) -> Vec<RFileInfo>

Returns the info of the files at the provided paths, from every open pack.

Source§

impl SessionState

Source

pub fn merge_files( &mut self, pack_key: &str, paths: &[ContainerPath], merged_path: &str, delete_source_files: bool, options: &MergeOptions, ) -> Result<MergeOutcome>

Merges compatible tables of a pack into a new one.

§Arguments
  • pack_key - Key of the pack with the tables.
  • paths - Paths of the tables to merge.
  • merged_path - Path of the merged table.
  • delete_source_files - If the merged tables are deleted afterwards.
  • options - How to merge the rows.
§Returns

The path of the merged table, or the conflicts that prevented the merge.

Source

pub fn update_table( &mut self, pack_key: &str, path: &ContainerPath, ) -> Result<(i32, i32, Vec<String>, Vec<String>)>

Updates a table of a pack to the version of the table in the game files.

§Returns

The old and new version, and the names of the fields deleted and added.

Source

pub fn export_tsv( &mut self, pack_key: &str, internal_path: &str, external_path: &Path, data_source: DataSource, tsv_keys_first: bool, ) -> Result<()>

Exports a table to a TSV file.

§Arguments
  • pack_key - Key of the pack with the table. Only used if data_source is a pack.
  • internal_path - Path of the table in its source.
  • external_path - Path of the TSV file to write.
  • data_source - Where the table is.
  • tsv_keys_first - If the TSV uses the old column order, with keys first.
Source

pub fn import_tsv( &mut self, pack_key: &str, internal_path: &str, external_path: &Path, ) -> Result<RFileDecoded>

Replaces a table of a pack with the contents of a TSV file, keeping the table’s GUID.

§Returns

The imported table.

Source

pub fn cascade_edition( &mut self, pack_key: &str, table_name: &str, definition: &Definition, changes: &[(Field, String, String)], ) -> Result<(Vec<ContainerPath>, Vec<RFileInfo>)>

Changes values referencing an edited key in every table of a pack.

§Arguments
  • pack_key - Key of the pack to edit.
  • table_name - Name of the table whose key was edited.
  • definition - Definition of the table whose key was edited.
  • changes - Edited field, and its value before and after the edit, of each change.
§Returns

The paths of the edited files, and their info.

Source

pub fn add_keys_to_key_deletes( &mut self, pack_key: &str, table_file_name: &str, key_table_name: &str, keys: &HashSet<String>, ) -> Result<Option<ContainerPath>>

Adds rows to a key deletes table of a pack, one per key.

§Arguments
  • pack_key - Key of the pack with the key deletes table.
  • table_file_name - File name of the key deletes table.
  • key_table_name - Name of the table the keys belong to.
  • keys - Keys to delete.
§Returns

The path of the edited table, or None if the table wasn’t found.

Source

pub fn reference_data( &mut self, table_name: &str, definition: &Definition, force_local_generation: bool, ) -> HashMap<i32, TableReferences>

Returns the valid values of the reference columns of a table, from the open packs and the dependencies.

§Arguments
  • table_name - Name of the table.
  • definition - Definition of the table.
  • force_local_generation - If the references to the open packs are regenerated even if they’re cached.
§Returns

The references of each reference column, by column index. Empty if there is no schema.

Source

pub fn table_reference_data( &mut self, request: &GetTableReferenceData, ) -> Result<TableReferenceData>

Returns the values each column of a table can reference, with their lookups.

§Errors

Fails if there is no schema, or it has no definition of the table with the requested version.

Source

pub fn find_definition( &self, pack_key: Option<&str>, table_name: &str, column: &str, value: &str, ) -> Result<FoundRow>

Finds the first row with a value in a column of a table.

Searches the open packs, then the parent packs, the game files and the Assembly Kit tables.

§Arguments
  • pack_key - If set, only this open pack is searched.
  • table_name - Name of the table, like factions_tables.
  • column - Name of the column. If it’s localised, the first key column is searched instead.
  • value - Value to search.
§Returns

Where the row is, and its values.

Source

pub fn find_loc( &self, pack_key: Option<&str>, loc_key: &str, ) -> Result<FoundRow>

Finds the first row of a Loc file with a key.

Searches the open packs, then the parent packs and then the game files.

§Arguments
  • pack_key - If set, only this open pack is searched.
  • loc_key - Key to search.
§Returns

Where the row is, and its values.

Source

pub fn row_locs(&mut self, row_ref: &RowRef) -> Result<RowLocs>

Returns the loc entries of a row of a DB table: the loc key of each localised column, with its text if it has one.

§Errors

Fails if the file is not a DB table, if the row doesn’t exist, or if the schema doesn’t say which columns make the loc keys of the table.

Returns the open packs a lookup searches, with their keys: only the provided one if set, or all of them.

§Errors

Fails if the provided pack is not open.

Source

pub fn search_references( &self, pack_key: Option<&str>, reference_map: &HashMap<String, Vec<String>>, value: &str, ) -> Result<Vec<Usage>>

Finds every row referencing a value, in the open packs, the parent packs and the game files.

§Arguments
  • pack_key - If set, only this open pack is searched.
  • reference_map - Columns to search, by table name.
  • value - Value to search.
§Returns

The rows referencing the value.

Source

pub fn find_usages(&self, request: &FindUsages) -> Result<Usages>

Finds the rows of other tables referencing a value of a table, taking the referencing columns from the schema.

Source

pub fn loc_key_source( &self, loc_key: &str, ) -> Option<(String, String, Vec<String>)>

Returns the table, column and key values a loc key was generated from, if it can be found in the dependencies.

Source

pub fn column_values( &self, table_name: &str, column_name: &str, include_packs: bool, include_dependencies: bool, ) -> HashSet<String>

Returns the distinct values of a column of a table.

§Arguments
  • table_name - Name of the table, like factions_tables.
  • column_name - Name of the column.
  • include_packs - If the open packs are searched.
  • include_dependencies - If the game files and parent packs are searched.
Source

pub fn column_values_page( &self, request: &GetColumnValues, ) -> Result<ColumnValues>

Returns a page of the distinct values of a column of a table, sorted.

§Errors

Fails if the schema has no definition of the table, or if the table has no column with the provided name.

Source

pub fn unused_numbers( &self, request: &GetUnusedNumbers, ) -> Result<UnusedNumbers>

Returns numbers above the highest one used in an integer column of a table, in the open packs and the dependencies.

§Errors

Fails if the schema has no definition of the table, if the table has no column with the provided name, if the column isn’t an integer one, or if its type has not enough numbers left.

Source

pub fn reference_values( &mut self, request: &GetReferenceValues, ) -> Result<ReferenceValues>

Returns a page of the values a reference column of a table can have, with their display text.

§Errors

Fails if the table has no column with the provided name, or if the column is not a reference.

Source

pub fn loc_source(&self, loc_key: &str) -> Option<LocSource>

Returns the table, column and key values a loc key was generated from, if it can be found in the dependencies.

Source

pub fn dependency_table_names(&self) -> Vec<String>

Returns the names of the tables in the game files.

Source

pub fn dependency_table_version(&self, table_name: &str) -> Result<i32>

Returns the version of a table in the game files.

Startpos, twad and CEO tables not in the game files return the latest version in the schema.

Source

pub fn dependency_tables(&self, table_name: &str) -> Result<Vec<RFile>>

Returns the tables with the provided name from the game files and the parent packs.

Source

pub fn dependency_table_versions(&self) -> DependencyTables

Returns the tables of the game files, and the custom tables of the schema, with their version.

Source

pub fn dependency_table_data( &self, table_name: &str, ) -> Result<DependencyTableData>

Returns every decoded table of a type in the game files and the parent packs.

Source§

impl SessionState

Source

pub fn table_info(&mut self, file: &FileRef) -> Result<TableInfo>

Returns the definition and row count of a table.

Source

pub fn table_rows(&mut self, request: &GetTableRows) -> Result<TableRows>

Returns a page of the rows of a table matching the request’s filters, with only the requested columns.

§Errors

Fails if the table can’t be read, or if the request names a column the table doesn’t have.

Source

pub fn edit_table(&mut self, request: &EditTable) -> Result<TableEdited>

Edits rows of a table of an open pack. If any edit fails, none is applied.

§Errors

Fails if the pack doesn’t have the table, or if an edit names a column the table doesn’t have, a row that doesn’t exist, or a value that doesn’t fit its column.

Source

fn copied_row_values( &mut self, edits: &[RowEdit], fields: &[Field], ) -> Result<BTreeMap<usize, Vec<(usize, DecodedData)>>>

Returns the values of the rows the inserts of some edits copy, by edit index, in the columns of the edited table with the same names.

§Arguments
  • edits - The edits, some of which may copy rows.
  • fields - Columns of the edited table, as rows see them.
§Errors

Fails if a copied row doesn’t exist, or if one of its values can’t be converted to the type of its column in the edited table.

Source

pub fn merge_tables(&mut self, request: &MergeTables) -> Result<TablesMerged>

Merges tables of the same type of a pack into a new one.

§Returns

The path of the merged table, or the conflicts that prevented the merge.

Source

pub fn upgrade_table(&mut self, request: &UpgradeTable) -> Result<TableUpgraded>

Updates a table of a pack to the version it has in the game files.

Source

pub fn rename_key(&mut self, request: &RenameKey) -> Result<FilesEdited>

Changes a value of a key column in every table of a pack, including the columns referencing it.

§Errors

Fails if the table has no definition, or no column with the provided name.

Source

pub fn add_key_deletes( &mut self, request: &AddKeyDeletes, ) -> Result<FilesEdited>

Adds rows to a key deletes table of a pack, one per key.

§Errors

Fails if the key deletes table doesn’t exist in the pack.

Source

pub fn export_table_tsv( &mut self, request: &ExportTsv, keys_first: bool, ) -> Result<()>

Writes a table from any source, except the Assembly Kit, to a TSV file.

§Arguments
  • request - Table to export, and where.
  • keys_first - If the TSV uses the old column order, with keys first.
Source

pub fn import_table_tsv(&mut self, request: &ImportTsv) -> Result<TableEdited>

Replaces a table of a pack with the contents of a TSV file, keeping its GUID.

Source

fn table(&mut self, file: &FileRef) -> Result<&TableInMemory>

Returns a DB or Loc table from any source, decoding it first if needed.

Source

fn decoded_table_file(&mut self, file: &FileRef) -> Result<&mut RFile>

Returns a DB or Loc file from an open pack or the dependencies, decoded.

Source§

impl SessionState

Source

pub fn optimize_pack( &mut self, pack_key: &str, options: &OptimizerOptions, ) -> Result<(HashSet<String>, HashSet<String>)>

Removes unchanged and duplicated data from a pack.

§Returns

The paths deleted and the paths added by the optimizer.

Source

pub fn patch_siege_ai( &mut self, pack_key: &str, ) -> Result<(String, Vec<ContainerPath>)>

Patches the SiegeAI of the siege maps of a pack, for Warhammer games.

§Returns

A message with the result, and the paths deleted.

Source

pub fn pack_map( &mut self, pack_key: &str, tile_maps: Vec<PathBuf>, tiles: Vec<(PathBuf, String)>, options: OptimizerOptions, ) -> Result<(Vec<ContainerPath>, Vec<ContainerPath>)>

Packs map tiles and tile maps into a pack.

§Arguments
  • pack_key - Key of the pack to add the maps to.
  • tile_maps - Paths on disk of the tile maps.
  • tiles - Paths on disk of the tiles, and their subfolder in the pack.
  • options - Options to optimize the added files.
§Returns

The paths added and the paths deleted.

Source

pub fn generate_missing_loc_data(&mut self) -> Result<Vec<ContainerPath>>

Adds the loc entries missing from the tables of the open packs.

§Returns

The paths of the files with the new entries.

Source

pub fn initialize_mymod_folder( &self, mymod_base_path: &Path, mod_game: &str, mod_name: &str, options: &MyModOptions, ) -> Result<PathBuf>

Creates the folder of a new MyMod, with the editor configs requested.

§Arguments
  • mymod_base_path - Folder containing the MyMods of all games.
  • mod_game - Folder name of the game of the MyMod.
  • mod_name - Name of the MyMod.
  • options - Editor support to set up.
§Returns

The path of the MyMod’s pack.

Source

pub fn pack_translation( &self, pack_key: &str, src_lang: &str, language: &str, ) -> Result<PackTranslation>

Returns the translation of a pack to a language, with the vanilla texts and their community fixes as base.

§Arguments
  • pack_key - Key of the pack to translate.
  • src_lang - Language the pack’s texts are written in.
  • language - Language to translate the pack to.
Source

pub fn generate_vanilla_translation_source( &self, src_lang: &str, settings: &Settings, ) -> Result<bool>

Generates the vanilla texts of a language from the game’s locale packs.

§Arguments
  • src_lang - Language to generate the texts of.
  • settings - Settings, to find the game’s install folder.
§Returns

If vanilla texts for that language are available, generated now or before.

Source

pub fn check_starpos_victory_conditions(&self, pack_key: &str) -> Result<()>

Checks that a pack has the victory objectives file, for the games that need it to build a startpos.

Source

pub fn build_starpos( &mut self, pack_key: &str, campaign_id: &str, process_hlp_spd_data: bool, settings: &Settings, ) -> Result<()>

Prepares the Assembly Kit to build the startpos of a campaign, with the tables of a pack.

§Arguments
  • pack_key - Key of the pack with the startpos tables.
  • campaign_id - Campaign to build the startpos for.
  • process_hlp_spd_data - If the HLP and SPD data are also built.
  • settings - Settings, to find the game’s install folder and Assembly Kit.
Source

pub fn build_starpos_post( &mut self, pack_key: &str, campaign_id: &str, process_hlp_spd_data: bool, cleanup: bool, settings: &Settings, ) -> Result<Vec<ContainerPath>>

Imports the startpos built by the Assembly Kit into a pack, or cleans up the files used to build it.

§Arguments
  • pack_key - Key of the pack to import the startpos into.
  • campaign_id - Campaign the startpos was built for.
  • process_hlp_spd_data - If the HLP and SPD data were also built.
  • cleanup - If this only cleans up the build files, instead of importing the startpos.
  • settings - Settings, to find the game’s install folder and Assembly Kit.
§Returns

The paths added to the pack.

Source

pub fn build_ceo( &mut self, pack_key: &str, akit_path: &Path, bob_exe_path: &Path, ) -> Result<()>

Builds ceo_data.ccd in the Assembly Kit from the CEO tables of a pack. See build_ceo.

Source

pub fn build_ceo_post( &mut self, pack_key: &str, akit_path: &Path, ) -> Result<FilesEdited>

Imports the ceo_data.ccd built by BOB into a pack.

§Returns

The paths added to the pack.

Source

pub fn build_ceo_entries( &mut self, pack_key: &str, entries: &[CeoEntryData], ) -> Result<FilesEdited>

Adds CEO entries (armour, career, traits and their locs) to a pack.

§Returns

The paths added to the pack.

Source

pub fn trait_ceos(&self) -> Vec<(String, String)>

Returns the key and name of the trait CEOs in the Assembly Kit.

Source

pub fn update_anim_ids( &mut self, pack_key: &str, starting_id: i32, offset: i32, ) -> Result<Vec<ContainerPath>>

Offsets the animation ids of a pack.

§Arguments
  • pack_key - Key of the pack to edit.
  • starting_id - Only ids from this one are changed.
  • offset - Amount to add to each id.
§Returns

The paths of the edited files.

Source

pub fn export_rigid_to_gltf( &mut self, rigid_model: &RigidModel, path: &Path, ) -> Result<()>

Exports a RigidModel to a glTF file.

Source

pub fn run_plugin_script( &mut self, request: &RunPluginScript, options: ExtractOptions, ) -> Result<PluginScriptRun>

Runs a plugin script over files of a pack, reading back into the pack the files it changes.

The files are extracted to a temp folder, keeping their paths in the pack, and passed to the script as arguments. Tables are extracted as TSV. Files the script deletes are left untouched in the pack.

§Arguments
  • request - The script, its pack, and the paths of the files and folders to pass to it.
  • options - Options for extracting the files.
§Returns

The paths read back into the pack, and an error message if the script failed.

Source§

impl SessionState

Source

pub fn optimize_pack_files( &mut self, pack_key: &str, options: &OptimizerOptions, ) -> Result<FilesChanged>

Removes unneeded data from a pack, returning the paths changed.

Source

pub fn patch_siege_ai_files(&mut self, pack_key: &str) -> Result<SiegeAiPatched>

Patches the siege maps of a pack, returning what was patched.

Source

pub fn pack_map_files( &mut self, pack_key: &str, tile_maps: Vec<PathBuf>, tiles: Vec<(PathBuf, String)>, options: OptimizerOptions, ) -> Result<FilesChanged>

Packs map tiles and tile maps into a pack, returning the paths changed.

Source

pub fn generate_missing_locs(&mut self) -> Result<FilesEdited>

Adds the missing loc entries of the tables of the open packs, returning the paths edited.

Source

pub fn update_anim_id_files( &mut self, pack_key: &str, starting_id: i32, offset: i32, ) -> Result<FilesEdited>

Offsets the animation ids of a pack, returning the paths edited.

Source

pub fn anims_by_skeleton(&mut self, skeleton: &str) -> FilePaths

Returns the sorted paths of the animations using a skeleton.

Source

pub fn export_gltf(&mut self, file: &FileRef, destination: &Path) -> Result<()>

Exports a RigidModel from any source to a glTF file.

§Errors

Fails if the file is not a RigidModel, or if it can’t be exported.

Source

pub fn init_mymod( &self, mymod_base_path: &Path, request: &InitMyMod, ) -> Result<MyModCreated>

Creates the folder of a new MyMod.

§Arguments
  • mymod_base_path - Folder containing the MyMods of all games.
  • request - The MyMod to create.
Source

pub fn list_translations( &self, request: &ListTranslations, ) -> Result<Translations>

Returns a page of the translation of the texts of a pack, sorted by key.

Source

pub fn startpos_campaigns(&self, pack_key: &str) -> Result<StartposCampaigns>

Returns the campaigns a startpos can be built for, and the one the last startpos of a pack was built for.

Source

pub fn start_startpos( &mut self, request: &StartStartpos, settings: &Settings, ) -> Result<()>

Starts building a startpos: checks the pack, prepares the Assembly Kit and launches the game.

The campaign is saved in the pack’s settings, to suggest it next time.

Source

pub fn validate_startpos( &self, request: &ValidateStartpos, ) -> Result<StartposValidation>

Checks the tables a campaign’s startpos is built from.

Source

pub fn generate_startpos( &mut self, request: &GenerateStartpos, settings: &Settings, ) -> Result<FilesEdited>

Generates the startpos of a campaign from the tables of a pack and the game’s files, and adds it to the pack.

The campaign is saved in the pack’s settings, to suggest it next time.

§Errors

Fails if the game isn’t supported, the dependencies aren’t loaded, the tables have errors, or the pack or game lack data the build needs.

Source

pub fn extract_startpos_tables( &mut self, request: &ExtractStartposTables, settings: &Settings, ) -> Result<FilesEdited>

Extracts the start_pos_* tables and the victory objectives of a campaign from its startpos (the pack’s, or the game’s), and adds the tables with rows and the objectives to the pack.

§Errors

Fails if the game isn’t supported, the dependencies aren’t loaded, or the startpos is missing or doesn’t fit the record layouts.

Source

pub fn keep_startpos_campaign( &mut self, request: &KeepStartposCampaign, ) -> Result<FilesChanged>

Removes the rows of a pack’s start_pos_* tables that don’t belong to a campaign, deleting the tables left without rows.

§Errors

Fails if the schema isn’t loaded, a table can’t be decoded, or no faction of the tables is in the campaign.

Source

pub fn compare_startpos_tables( &self, request: &CompareStartposTables, settings: &Settings, ) -> Result<StartposComparison>

Compares the tables extracted from a campaign’s startpos with the tables it’s built from.

§Errors

Fails like Self::extract_startpos_tables, or if the extracted values don’t fit the schema.

Source

fn startpos_extraction( &self, pack_key: &str, campaign: &str, settings: &Settings, ) -> Result<(ExtractedTables, StartposTables)>

Extracts the tables of a campaign’s startpos, returning them with the tables the startpos is built from.

Source

fn check_startpos_generator_support(&self) -> Result<()>

Checks that the startpos generator supports the game and has its files loaded.

Source

fn startpos_layout( &self, tables: &StartposTables, campaign: &str, settings: &Settings, ) -> Result<StartposLayout>

Returns the record layouts to write or read a campaign’s startpos with.

Source

pub fn finish_startpos( &mut self, cancel: bool, settings: &Settings, ) -> Result<FilesEdited>

Finishes building a startpos: imports it into its pack, or cancels the build, and cleans up the build files.

§Errors

Fails if there’s no build started.

Source§

impl SessionState

Source

pub fn new(session: Arc<Session>) -> Self

Creates the state of a new session, with Warhammer 3 selected and nothing loaded.

§Arguments
  • session - The session this state belongs to.
Source

pub fn game(&self) -> &GameInfo

Returns the game currently selected.

Source

pub fn session_status(&self) -> SessionStatus

Returns the selected game, what’s loaded for it, and the open packs.

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
§

impl<T> MaybeSend for T

§

impl<T> MaybeSync for T

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more