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: SupportedGamesRegistry of every game RPFM supports.
game: GameInfoThe game currently selected.
schema: Option<Schema>Schema of the selected game, if it could be loaded.
first_game_change_done: boolIf 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: DependenciesVanilla 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
impl SessionState
Sourcepub fn set_game_selected(
&mut self,
game_key: &str,
rebuild_dependencies: bool,
settings: &Settings,
disable_uuid_regeneration: bool,
) -> Result<(CompressionFormat, Option<DependenciesInfo>)>
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.
Sourcepub fn decode_dependency_tables(&mut self)
pub fn decode_dependency_tables(&mut self)
Decodes the tables of the dependencies with the loaded schema.
Sourcepub fn generate_dependencies_cache(
&mut self,
settings: &Settings,
ignore_game_files_in_ak: bool,
) -> Result<DependenciesInfo>
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.
Sourcepub fn rebuild_dependencies(
&mut self,
only_parent_packs: bool,
settings: &Settings,
) -> Result<DependenciesInfo>
pub fn rebuild_dependencies( &mut self, only_parent_packs: bool, settings: &Settings, ) -> Result<DependenciesInfo>
Sourcepub fn rebuild_dependencies_after_schema_update(
&mut self,
settings: &Settings,
) -> Result<()>
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.
Sourcefn load_dependencies(
&mut self,
cache_path: Option<&Path>,
decode_tables: bool,
settings: &Settings,
) -> Result<()>
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, orNoneto 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.
Sourcepub fn dependencies_info(&self) -> DependenciesInfo
pub fn dependencies_info(&self) -> DependenciesInfo
Returns the files of the dependencies of the selected game.
Source§impl SessionState
impl SessionState
Sourcepub 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>
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 returnsfalse, the check stops early.
§Returns
The updated diagnostics, or None if the check was stopped.
Sourcepub fn run_diagnostics(
&mut self,
request: &RunDiagnostics,
settings: &Settings,
on_progress: &(dyn Fn(usize, usize) -> bool + Sync),
) -> Option<DiagnosticsSummary>
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 returnsfalse, the check stops early.
§Returns
A summary of the results, or None if the check was stopped, keeping the results of the last check.
Sourcepub fn list_diagnostics(
&self,
request: &ListDiagnostics,
) -> Result<DiagnosticList>
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.
Sourcepub fn diagnostics_report(&self) -> Result<Diagnostics>
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.
Sourcepub fn ignore_diagnostics(
&mut self,
request: &IgnoreDiagnostics,
) -> Result<Done>
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.
Sourcepub fn lua_hovers(
&mut self,
source: &str,
settings: &Settings,
) -> Vec<(u64, u64, u64, u64, String)>
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.
Sourcepub fn lua_run_tests(
&mut self,
test_source: &str,
campaign: Option<String>,
settings: &Settings,
) -> Result<LuaTestReport>
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. IfNone, 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
impl SessionState
Sourcepub fn list_files(&self, request: &ListFiles) -> Result<FileList>
pub fn list_files(&self, request: &ListFiles) -> Result<FileList>
Returns a page of the files of a source matching the request, sorted by path.
Sourcepub 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>)>
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.
Sourcepub fn add_files_from_pack(
&mut self,
target_key: &str,
source_key: &str,
paths: &[ContainerPath],
) -> Result<(Vec<ContainerPath>, Vec<String>, Option<String>)>
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.
Sourcepub 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>)>
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.
Sourcepub 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>>
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 ifdata_sourceis 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.
Sourcepub fn delete_from_animpack(
&mut self,
pack_key: &str,
anim_pack_path: &str,
paths: &[ContainerPath],
) -> Result<()>
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.
Sourcepub fn view_data(
&mut self,
file: &FileRef,
enable_esf_editor: bool,
) -> Result<ViewData>
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.
Sourcepub fn decode_file(
&mut self,
pack_key: &str,
path: &str,
data_source: DataSource,
enable_esf_editor: bool,
) -> Result<DecodedFile>
pub fn decode_file( &mut self, pack_key: &str, path: &str, data_source: DataSource, enable_esf_editor: bool, ) -> Result<DecodedFile>
Sourcepub fn save_file_from_view(
&mut self,
pack_key: &str,
path: &str,
decoded: RFileDecoded,
) -> Result<()>
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.
Sourcepub fn delete_files(
&mut self,
pack_key: &str,
paths: &[ContainerPath],
) -> Result<Vec<ContainerPath>>
pub fn delete_files( &mut self, pack_key: &str, paths: &[ContainerPath], ) -> Result<Vec<ContainerPath>>
Sourcepub fn paste_files(&mut self, request: &PasteFiles) -> Result<FilesPasted>
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.
Sourcepub fn duplicate_files(
&mut self,
pack_key: &str,
paths: &[ContainerPath],
) -> Result<Vec<ContainerPath>>
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.
Sourcepub 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>>
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.
Sourcepub fn rename_files(
&mut self,
pack_key: &str,
renames: &[(ContainerPath, ContainerPath)],
) -> Result<Vec<(ContainerPath, ContainerPath)>>
pub fn rename_files( &mut self, pack_key: &str, renames: &[(ContainerPath, ContainerPath)], ) -> Result<Vec<(ContainerPath, ContainerPath)>>
Sourcepub fn file_exists(&self, pack_key: &str, path: &str) -> Result<bool>
pub fn file_exists(&self, pack_key: &str, path: &str) -> Result<bool>
Returns if a file exists in a pack.
Sourcepub fn open_in_external_program(
&mut self,
pack_key: &str,
path: &str,
options: ExtractOptions,
) -> Result<PathBuf>
pub fn open_in_external_program( &mut self, pack_key: &str, path: &str, options: ExtractOptions, ) -> Result<PathBuf>
Sourcepub fn save_file_from_external(
&mut self,
pack_key: &str,
path: &str,
external_path: &Path,
) -> Result<()>
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.
Sourcepub fn save_files_and_optimize(
&mut self,
pack_key: &str,
files: Vec<RFile>,
optimizer_options: Option<OptimizerOptions>,
) -> Result<FilesChanged>
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.
Sourcepub fn set_video_format(
&mut self,
pack_key: &str,
path: &str,
format: SupportedFormats,
) -> Result<()>
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.
Sourcepub fn files_from_all_sources(
&self,
paths: &[ContainerPath],
lowercase_paths: bool,
) -> HashMap<DataSource, HashMap<String, RFile>>
pub fn files_from_all_sources( &self, paths: &[ContainerPath], lowercase_paths: bool, ) -> HashMap<DataSource, HashMap<String, RFile>>
Sourcepub fn anim_paths_by_skeleton(&mut self, skeleton_name: &str) -> HashSet<String>
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.
Sourcepub fn import_dependencies(
&mut self,
pack_key: &str,
paths_by_source: &BTreeMap<DataSource, Vec<ContainerPath>>,
) -> Result<(Vec<ContainerPath>, Vec<String>, Option<String>)>
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
impl SessionState
Sourcepub fn create_file(&mut self, request: &CreateFile) -> Result<FileEntry>
pub fn create_file(&mut self, request: &CreateFile) -> Result<FileEntry>
Sourcepub fn add_disk_files(
&mut self,
request: &AddFilesFromDisk,
include_base_folder: bool,
) -> Result<FilesAdded>
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.
Sourcepub fn copy_files_to_pack(&mut self, request: &CopyFiles) -> Result<FilesAdded>
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.
Sourcepub fn delete_paths(&mut self, request: &DeleteFiles) -> Result<FilesDeleted>
pub fn delete_paths(&mut self, request: &DeleteFiles) -> Result<FilesDeleted>
Deletes files and folders from an open pack.
Sourcepub fn rename_paths(&mut self, request: &RenameFiles) -> Result<FilesRenamed>
pub fn rename_paths(&mut self, request: &RenameFiles) -> Result<FilesRenamed>
Renames or moves files and folders of an open pack.
Sourcepub fn duplicate_paths(
&mut self,
request: &DuplicateFiles,
) -> Result<FilesAdded>
pub fn duplicate_paths( &mut self, request: &DuplicateFiles, ) -> Result<FilesAdded>
Duplicates files of an open pack in the same pack.
Sourcepub fn extract_paths(
&mut self,
request: &ExtractFiles,
options: ExtractOptions,
) -> Result<FilesExtracted>
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.
Sourcepub fn read_file(
&mut self,
request: &ReadFile,
enable_esf_editor: bool,
disable_uuid_regeneration: bool,
) -> Result<FileContents>
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.
Sourcepub fn write_file(&mut self, request: &WriteFile) -> Result<()>
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.
Sourcepub fn list_animpack(&mut self, file: &FileRef) -> Result<FileList>
pub fn list_animpack(&mut self, file: &FileRef) -> Result<FileList>
Returns the files inside an AnimPack of any source, sorted by path.
Sourcepub fn add_to_animpack(&mut self, request: &AddToAnimPack) -> Result<FilesAdded>
pub fn add_to_animpack(&mut self, request: &AddToAnimPack) -> Result<FilesAdded>
Copies files of an open pack into an AnimPack of an open pack.
Sourcepub fn extract_from_animpack(
&mut self,
request: &ExtractFromAnimPack,
) -> Result<FilesAdded>
pub fn extract_from_animpack( &mut self, request: &ExtractFromAnimPack, ) -> Result<FilesAdded>
Copies files of an AnimPack of any source into an open pack.
Sourcepub fn delete_in_animpack(&mut self, request: &DeleteFromAnimPack) -> Result<()>
pub fn delete_in_animpack(&mut self, request: &DeleteFromAnimPack) -> Result<()>
Deletes files from an AnimPack of an open pack.
Sourcefn animpack_container_paths(
&mut self,
file: &FileRef,
paths: &[String],
) -> Result<Vec<ContainerPath>>
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.
Sourcepub(super) fn check_file_exists(&self, file: &FileRef) -> Result<()>
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.
pub(super) fn pack_container_paths( &self, pack_key: &str, paths: &[String], ) -> Result<Vec<ContainerPath>>
Source§impl SessionState
impl SessionState
Sourcepub fn open_packs(
&mut self,
paths: &[PathBuf],
lazy_loading: bool,
) -> Result<(String, ContainerInfo)>
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.
Sourcepub fn open_ca_packs(
&mut self,
settings: &Settings,
) -> Result<(String, ContainerInfo)>
pub fn open_ca_packs( &mut self, settings: &Settings, ) -> Result<(String, ContainerInfo)>
Sourcepub fn close_pack(&mut self, pack_key: &str) -> Result<()>
pub fn close_pack(&mut self, pack_key: &str) -> Result<()>
Closes a pack without saving it.
Sourcepub fn close_all_packs(&mut self)
pub fn close_all_packs(&mut self)
Closes all open packs without saving them.
Sourcepub fn save_pack(
&mut self,
pack_key: &str,
path: Option<&Path>,
options: SaveOptions,
) -> Result<ContainerInfo>
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. IfNone, 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.
Sourcepub fn update_pack(&mut self, request: &UpdatePack) -> Result<PackDetails>
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.
Sourcepub fn pack_summary(&self, pack_key: &str) -> Result<PackSummary>
pub fn pack_summary(&self, pack_key: &str) -> Result<PackSummary>
Returns the short description of an open pack.
Sourcepub fn files_info(&self, request: &GetFilesInfo) -> Result<FilesInfo>
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.
Sourcepub fn pack_details(&self, pack_key: &str) -> Result<PackDetails>
pub fn pack_details(&self, pack_key: &str) -> Result<PackDetails>
Returns the details of an open pack.
Sourcepub fn set_compression_format(
&mut self,
pack_key: &str,
compression_format: CompressionFormat,
) -> Result<CompressionFormat>
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.
Sourcepub fn pack_settings(&self, pack_key: &str) -> Result<PackSettings>
pub fn pack_settings(&self, pack_key: &str) -> Result<PackSettings>
Returns the settings of a pack.
Sourcepub fn add_pack_ignored_diagnostics_line(
&mut self,
pack_key: &str,
line: String,
) -> Result<()>
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.
Sourcepub fn pack_operational_mode(&self, pack_key: &str) -> OperationalMode
pub fn pack_operational_mode(&self, pack_key: &str) -> OperationalMode
Returns the operational mode of a pack. Unknown packs are in normal mode.
Sourcepub fn pack_settings_values(&self, pack_key: &str) -> Result<PackSettingsValues>
pub fn pack_settings_values(&self, pack_key: &str) -> Result<PackSettingsValues>
Returns the settings of a pack.
Sourcepub fn update_pack_settings(
&mut self,
request: &UpdatePackSettings,
) -> Result<PackSettingsValues>
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.
Sourcepub fn note_entries(&self, pack_key: &str, path: &str) -> Result<Vec<NoteEntry>>
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.
Sourcepub fn add_note_entry(&mut self, request: &AddNote) -> Result<NoteEntry>
pub fn add_note_entry(&mut self, request: &AddNote) -> Result<NoteEntry>
Sourcepub fn notes_for_path(&self, pack_key: &str, path: &str) -> Result<Vec<Note>>
pub fn notes_for_path(&self, pack_key: &str, path: &str) -> Result<Vec<Note>>
Returns the notes of a pack under a path.
Sourcepub fn delete_note(&mut self, pack_key: &str, path: &str, id: u64) -> Result<()>
pub fn delete_note(&mut self, pack_key: &str, path: &str, id: u64) -> Result<()>
Deletes a note from a pack.
Sourcepub fn mark_packs_changed(&mut self, pack_key: Option<&str>)
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, orNoneif any open pack may have changed.
Sourcepub fn autosave(&mut self, settings: &Settings)
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.
Sourcefn autosave_to(&mut self, settings: &Settings, autosave_path: PathBuf)
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.
Sourcepub fn wait_for_autosave(&mut self)
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.
Sourcepub fn missing_definitions(
&mut self,
pack_key: &str,
) -> Result<MissingDefinitions>
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.
Sourcepub fn live_export(
&mut self,
pack_key: &str,
settings: &Settings,
disable_uuid_regeneration: bool,
tsv_keys_first: bool,
) -> Result<()>
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.
Sourcefn insert_pack(&mut self, pack: Pack) -> String
fn insert_pack(&mut self, pack: Pack) -> String
Source§impl SessionState
impl SessionState
Sourcepub fn update_schema_from_asskit(
&mut self,
settings: &Settings,
ignore_game_files_in_ak: bool,
disable_uuid_regeneration: bool,
) -> Result<()>
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.
Sourcepub fn reload_schema(&mut self, disable_uuid_regeneration: bool)
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.
Sourcepub fn save_schema(&mut self, schema: Schema) -> Result<()>
pub fn save_schema(&mut self, schema: Schema) -> Result<()>
Saves a schema to disk as the schema of the selected game, and loads it.
Sourcepub fn save_local_schema_patches(
&self,
patches: &HashMap<String, DefinitionPatch>,
) -> Result<()>
pub fn save_local_schema_patches( &self, patches: &HashMap<String, DefinitionPatch>, ) -> Result<()>
Saves local patches for the schema of the selected game.
Sourcepub fn remove_local_schema_patches_for_table(
&self,
table_name: &str,
) -> Result<()>
pub fn remove_local_schema_patches_for_table( &self, table_name: &str, ) -> Result<()>
Removes the local schema patches of a table.
Sourcepub fn remove_local_schema_patches_for_table_and_field(
&self,
table_name: &str,
field_name: &str,
) -> Result<()>
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.
Sourcepub fn import_schema_patches(
&mut self,
patches: &HashMap<String, DefinitionPatch>,
) -> Result<()>
pub fn import_schema_patches( &mut self, patches: &HashMap<String, DefinitionPatch>, ) -> Result<()>
Adds patches to the schema of the selected game, and saves it.
Sourcepub fn custom_table_names(&self) -> Result<Vec<String>>
pub fn custom_table_names(&self) -> Result<Vec<String>>
Returns the names of the startpos and twad tables in the schema.
Sourcepub fn table_definition(
&self,
request: &GetTableDefinition,
) -> Result<TableDefinition>
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.
Sourcepub fn schema_tables(&self, prefix: &str) -> Result<SchemaTables>
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.
Sourcepub fn patch_column(
&mut self,
request: &PatchColumn,
disable_uuid_regeneration: bool,
) -> Result<()>
pub fn patch_column( &mut self, request: &PatchColumn, disable_uuid_regeneration: bool, ) -> Result<()>
Sourcepub fn remove_patches(
&mut self,
request: &RemovePatches,
disable_uuid_regeneration: bool,
) -> Result<()>
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.
Sourcepub fn raw_definitions(
&self,
table_name: &str,
version: Option<i32>,
) -> Result<RawDefinitions>
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.
Sourcepub fn set_definition(
&mut self,
request: &SetDefinition,
disable_uuid_regeneration: bool,
) -> Result<()>
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.
Sourcepub fn delete_definition_and_save(
&mut self,
request: &DeleteDefinition,
disable_uuid_regeneration: bool,
) -> Result<()>
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.
Sourcepub fn referencing_columns_of(
&self,
request: &GetReferencingColumns,
) -> Result<ReferencingColumns>
pub fn referencing_columns_of( &self, request: &GetReferencingColumns, ) -> Result<ReferencingColumns>
Returns the columns of other tables referencing each column of a table.
Sourcepub fn import_patches(
&mut self,
request: &ImportPatches,
disable_uuid_regeneration: bool,
) -> Result<()>
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.
Sourcepub fn definitions_by_table_name(
&self,
table_name: &str,
) -> Result<Vec<Definition>>
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.
Sourcepub fn definition_patches(
&self,
table_name: &str,
version: i32,
) -> Result<DefinitionPatch>
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.
Sourcepub fn table_patches(&self, request: &GetTablePatches) -> Result<TablePatches>
pub fn table_patches(&self, request: &GetTablePatches) -> Result<TablePatches>
Returns the patches of a definition of a table, by column name.
Source§impl SessionState
impl SessionState
Sourcefn global_search_replace(
&mut self,
search: GlobalSearch,
matches: &[MatchHolder],
) -> Result<(GlobalSearch, Vec<RFileInfo>)>
fn global_search_replace( &mut self, search: GlobalSearch, matches: &[MatchHolder], ) -> Result<(GlobalSearch, Vec<RFileInfo>)>
Sourcepub fn run_search(&mut self, request: &RunSearch) -> Result<SearchSummary>
pub fn run_search(&mut self, request: &RunSearch) -> Result<SearchSummary>
Searches text, keeping the matches for Self::list_search_matches.
§Returns
A summary of the matches.
Sourcepub fn list_search_matches(
&self,
request: &ListSearchMatches,
) -> Result<SearchMatchList>
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.
Sourcepub fn replace_search_matches(
&mut self,
request: &ReplaceSearchMatches,
) -> Result<SearchReplaced>
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.
Sourcepub fn search_report(&self) -> Result<SearchReport>
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.
Sourcefn files_info_in_all_packs(&self, paths: &[ContainerPath]) -> Vec<RFileInfo>
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
impl SessionState
Sourcepub fn merge_files(
&mut self,
pack_key: &str,
paths: &[ContainerPath],
merged_path: &str,
delete_source_files: bool,
options: &MergeOptions,
) -> Result<MergeOutcome>
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.
Sourcepub fn update_table(
&mut self,
pack_key: &str,
path: &ContainerPath,
) -> Result<(i32, i32, Vec<String>, Vec<String>)>
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.
Sourcepub fn export_tsv(
&mut self,
pack_key: &str,
internal_path: &str,
external_path: &Path,
data_source: DataSource,
tsv_keys_first: bool,
) -> Result<()>
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 ifdata_sourceis 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.
Sourcepub fn import_tsv(
&mut self,
pack_key: &str,
internal_path: &str,
external_path: &Path,
) -> Result<RFileDecoded>
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.
Sourcepub fn cascade_edition(
&mut self,
pack_key: &str,
table_name: &str,
definition: &Definition,
changes: &[(Field, String, String)],
) -> Result<(Vec<ContainerPath>, Vec<RFileInfo>)>
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.
Sourcepub 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>>
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.
Sourcepub fn reference_data(
&mut self,
table_name: &str,
definition: &Definition,
force_local_generation: bool,
) -> HashMap<i32, TableReferences>
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.
Sourcepub fn table_reference_data(
&mut self,
request: &GetTableReferenceData,
) -> Result<TableReferenceData>
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.
Sourcepub fn find_definition(
&self,
pack_key: Option<&str>,
table_name: &str,
column: &str,
value: &str,
) -> Result<FoundRow>
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, likefactions_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.
Sourcepub fn row_locs(&mut self, row_ref: &RowRef) -> Result<RowLocs>
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.
Sourcefn packs_to_search<'a>(
&'a self,
pack_key: Option<&'a str>,
) -> Result<Vec<(&'a str, &'a Pack)>>
fn packs_to_search<'a>( &'a self, pack_key: Option<&'a str>, ) -> Result<Vec<(&'a str, &'a Pack)>>
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.
Sourcepub fn search_references(
&self,
pack_key: Option<&str>,
reference_map: &HashMap<String, Vec<String>>,
value: &str,
) -> Result<Vec<Usage>>
pub fn search_references( &self, pack_key: Option<&str>, reference_map: &HashMap<String, Vec<String>>, value: &str, ) -> Result<Vec<Usage>>
Sourcepub fn find_usages(&self, request: &FindUsages) -> Result<Usages>
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.
Sourcepub fn loc_key_source(
&self,
loc_key: &str,
) -> Option<(String, String, Vec<String>)>
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.
Sourcepub fn column_values(
&self,
table_name: &str,
column_name: &str,
include_packs: bool,
include_dependencies: bool,
) -> HashSet<String>
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, likefactions_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.
Sourcepub fn column_values_page(
&self,
request: &GetColumnValues,
) -> Result<ColumnValues>
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.
Sourcepub fn unused_numbers(
&self,
request: &GetUnusedNumbers,
) -> Result<UnusedNumbers>
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.
Sourcepub fn reference_values(
&mut self,
request: &GetReferenceValues,
) -> Result<ReferenceValues>
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.
Sourcepub fn loc_source(&self, loc_key: &str) -> Option<LocSource>
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.
Sourcepub fn dependency_table_names(&self) -> Vec<String>
pub fn dependency_table_names(&self) -> Vec<String>
Returns the names of the tables in the game files.
Sourcepub fn dependency_table_version(&self, table_name: &str) -> Result<i32>
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.
Sourcepub fn dependency_tables(&self, table_name: &str) -> Result<Vec<RFile>>
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.
Sourcepub fn dependency_table_versions(&self) -> DependencyTables
pub fn dependency_table_versions(&self) -> DependencyTables
Returns the tables of the game files, and the custom tables of the schema, with their version.
Sourcepub fn dependency_table_data(
&self,
table_name: &str,
) -> Result<DependencyTableData>
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
impl SessionState
Sourcepub fn table_info(&mut self, file: &FileRef) -> Result<TableInfo>
pub fn table_info(&mut self, file: &FileRef) -> Result<TableInfo>
Returns the definition and row count of a table.
Sourcepub fn table_rows(&mut self, request: &GetTableRows) -> Result<TableRows>
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.
Sourcepub fn edit_table(&mut self, request: &EditTable) -> Result<TableEdited>
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.
Sourcefn copied_row_values(
&mut self,
edits: &[RowEdit],
fields: &[Field],
) -> Result<BTreeMap<usize, Vec<(usize, DecodedData)>>>
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.
Sourcepub fn merge_tables(&mut self, request: &MergeTables) -> Result<TablesMerged>
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.
Sourcepub fn upgrade_table(&mut self, request: &UpgradeTable) -> Result<TableUpgraded>
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.
Sourcepub fn rename_key(&mut self, request: &RenameKey) -> Result<FilesEdited>
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.
Sourcepub fn add_key_deletes(
&mut self,
request: &AddKeyDeletes,
) -> Result<FilesEdited>
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.
Sourcepub fn export_table_tsv(
&mut self,
request: &ExportTsv,
keys_first: bool,
) -> Result<()>
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.
Sourcepub fn import_table_tsv(&mut self, request: &ImportTsv) -> Result<TableEdited>
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.
Sourcefn table(&mut self, file: &FileRef) -> Result<&TableInMemory>
fn table(&mut self, file: &FileRef) -> Result<&TableInMemory>
Returns a DB or Loc table from any source, decoding it first if needed.
Sourcefn decoded_table_file(&mut self, file: &FileRef) -> Result<&mut RFile>
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
impl SessionState
Sourcepub fn optimize_pack(
&mut self,
pack_key: &str,
options: &OptimizerOptions,
) -> Result<(HashSet<String>, HashSet<String>)>
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.
Sourcepub fn patch_siege_ai(
&mut self,
pack_key: &str,
) -> Result<(String, Vec<ContainerPath>)>
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.
Sourcepub fn pack_map(
&mut self,
pack_key: &str,
tile_maps: Vec<PathBuf>,
tiles: Vec<(PathBuf, String)>,
options: OptimizerOptions,
) -> Result<(Vec<ContainerPath>, Vec<ContainerPath>)>
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.
Sourcepub fn generate_missing_loc_data(&mut self) -> Result<Vec<ContainerPath>>
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.
Sourcepub fn initialize_mymod_folder(
&self,
mymod_base_path: &Path,
mod_game: &str,
mod_name: &str,
options: &MyModOptions,
) -> Result<PathBuf>
pub fn initialize_mymod_folder( &self, mymod_base_path: &Path, mod_game: &str, mod_name: &str, options: &MyModOptions, ) -> Result<PathBuf>
Sourcepub fn pack_translation(
&self,
pack_key: &str,
src_lang: &str,
language: &str,
) -> Result<PackTranslation>
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.
Sourcepub fn generate_vanilla_translation_source(
&self,
src_lang: &str,
settings: &Settings,
) -> Result<bool>
pub fn generate_vanilla_translation_source( &self, src_lang: &str, settings: &Settings, ) -> Result<bool>
Sourcepub fn check_starpos_victory_conditions(&self, pack_key: &str) -> Result<()>
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.
Sourcepub fn build_starpos(
&mut self,
pack_key: &str,
campaign_id: &str,
process_hlp_spd_data: bool,
settings: &Settings,
) -> Result<()>
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.
Sourcepub fn build_starpos_post(
&mut self,
pack_key: &str,
campaign_id: &str,
process_hlp_spd_data: bool,
cleanup: bool,
settings: &Settings,
) -> Result<Vec<ContainerPath>>
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.
Sourcepub fn build_ceo(
&mut self,
pack_key: &str,
akit_path: &Path,
bob_exe_path: &Path,
) -> Result<()>
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.
Sourcepub fn build_ceo_post(
&mut self,
pack_key: &str,
akit_path: &Path,
) -> Result<FilesEdited>
pub fn build_ceo_post( &mut self, pack_key: &str, akit_path: &Path, ) -> Result<FilesEdited>
Sourcepub fn build_ceo_entries(
&mut self,
pack_key: &str,
entries: &[CeoEntryData],
) -> Result<FilesEdited>
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.
Sourcepub fn trait_ceos(&self) -> Vec<(String, String)>
pub fn trait_ceos(&self) -> Vec<(String, String)>
Returns the key and name of the trait CEOs in the Assembly Kit.
Sourcepub fn update_anim_ids(
&mut self,
pack_key: &str,
starting_id: i32,
offset: i32,
) -> Result<Vec<ContainerPath>>
pub fn update_anim_ids( &mut self, pack_key: &str, starting_id: i32, offset: i32, ) -> Result<Vec<ContainerPath>>
Sourcepub fn export_rigid_to_gltf(
&mut self,
rigid_model: &RigidModel,
path: &Path,
) -> Result<()>
pub fn export_rigid_to_gltf( &mut self, rigid_model: &RigidModel, path: &Path, ) -> Result<()>
Exports a RigidModel to a glTF file.
Sourcepub fn run_plugin_script(
&mut self,
request: &RunPluginScript,
options: ExtractOptions,
) -> Result<PluginScriptRun>
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
impl SessionState
Sourcepub fn optimize_pack_files(
&mut self,
pack_key: &str,
options: &OptimizerOptions,
) -> Result<FilesChanged>
pub fn optimize_pack_files( &mut self, pack_key: &str, options: &OptimizerOptions, ) -> Result<FilesChanged>
Removes unneeded data from a pack, returning the paths changed.
Sourcepub fn patch_siege_ai_files(&mut self, pack_key: &str) -> Result<SiegeAiPatched>
pub fn patch_siege_ai_files(&mut self, pack_key: &str) -> Result<SiegeAiPatched>
Patches the siege maps of a pack, returning what was patched.
Sourcepub fn pack_map_files(
&mut self,
pack_key: &str,
tile_maps: Vec<PathBuf>,
tiles: Vec<(PathBuf, String)>,
options: OptimizerOptions,
) -> Result<FilesChanged>
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.
Sourcepub fn generate_missing_locs(&mut self) -> Result<FilesEdited>
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.
Sourcepub fn update_anim_id_files(
&mut self,
pack_key: &str,
starting_id: i32,
offset: i32,
) -> Result<FilesEdited>
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.
Sourcepub fn anims_by_skeleton(&mut self, skeleton: &str) -> FilePaths
pub fn anims_by_skeleton(&mut self, skeleton: &str) -> FilePaths
Returns the sorted paths of the animations using a skeleton.
Sourcepub fn export_gltf(&mut self, file: &FileRef, destination: &Path) -> Result<()>
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.
Sourcepub fn init_mymod(
&self,
mymod_base_path: &Path,
request: &InitMyMod,
) -> Result<MyModCreated>
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.
Sourcepub fn list_translations(
&self,
request: &ListTranslations,
) -> Result<Translations>
pub fn list_translations( &self, request: &ListTranslations, ) -> Result<Translations>
Returns a page of the translation of the texts of a pack, sorted by key.
Sourcepub fn startpos_campaigns(&self, pack_key: &str) -> Result<StartposCampaigns>
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.
Sourcepub fn start_startpos(
&mut self,
request: &StartStartpos,
settings: &Settings,
) -> Result<()>
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.
Sourcepub fn validate_startpos(
&self,
request: &ValidateStartpos,
) -> Result<StartposValidation>
pub fn validate_startpos( &self, request: &ValidateStartpos, ) -> Result<StartposValidation>
Checks the tables a campaign’s startpos is built from.
Sourcepub fn generate_startpos(
&mut self,
request: &GenerateStartpos,
settings: &Settings,
) -> Result<FilesEdited>
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.
Sourcepub fn extract_startpos_tables(
&mut self,
request: &ExtractStartposTables,
settings: &Settings,
) -> Result<FilesEdited>
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.
Sourcepub fn keep_startpos_campaign(
&mut self,
request: &KeepStartposCampaign,
) -> Result<FilesChanged>
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.
Sourcepub fn compare_startpos_tables(
&self,
request: &CompareStartposTables,
settings: &Settings,
) -> Result<StartposComparison>
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.
Sourcefn startpos_extraction(
&self,
pack_key: &str,
campaign: &str,
settings: &Settings,
) -> Result<(ExtractedTables, StartposTables)>
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.
Sourcefn check_startpos_generator_support(&self) -> Result<()>
fn check_startpos_generator_support(&self) -> Result<()>
Checks that the startpos generator supports the game and has its files loaded.
Sourcefn startpos_layout(
&self,
tables: &StartposTables,
campaign: &str,
settings: &Settings,
) -> Result<StartposLayout>
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.
Sourcepub fn finish_startpos(
&mut self,
cancel: bool,
settings: &Settings,
) -> Result<FilesEdited>
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
impl SessionState
Sourcepub fn new(session: Arc<Session>) -> Self
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.
Sourcepub fn session_status(&self) -> SessionStatus
pub fn session_status(&self) -> SessionStatus
Returns the selected game, what’s loaded for it, and the open packs.
Auto Trait Implementations§
impl !RefUnwindSafe for SessionState
impl !UnwindSafe for SessionState
impl Freeze for SessionState
impl Send for SessionState
impl Sync for SessionState
impl Unpin for SessionState
impl UnsafeUnpin for SessionState
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreimpl<T> MaybeSend for T
impl<T> MaybeSync for T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.