pub struct EndfRetriever { /* private fields */ }Expand description
ENDF file retrieval manager with local caching.
Implementations§
Source§impl EndfRetriever
impl EndfRetriever
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new retriever with default cache location (~/.cache/nereids/endf/).
Sourcepub fn with_cache_dir(cache_dir: impl Into<PathBuf>) -> Self
pub fn with_cache_dir(cache_dir: impl Into<PathBuf>) -> Self
Create a retriever with a custom cache directory.
Sourcepub fn cache_dir(&self, library: EndfLibrary) -> PathBuf
pub fn cache_dir(&self, library: EndfLibrary) -> PathBuf
Get the cache directory for a specific library.
Public so the GUI can show users exactly where to drop a manually- downloaded ENDF file when a fetch fails (issue #523).
Sourcepub fn cache_file_path(
&self,
isotope: &Isotope,
library: EndfLibrary,
) -> PathBuf
pub fn cache_file_path( &self, isotope: &Isotope, library: EndfLibrary, ) -> PathBuf
Get the cached ENDF file path for an isotope.
Public so callers can present the exact target path for manual file
drops; see Self::install_local_endf for the programmatic equivalent.
Sourcepub fn get_endf_file(
&self,
isotope: &Isotope,
library: EndfLibrary,
mat: u32,
) -> Result<(PathBuf, String), EndfRetrievalError>
pub fn get_endf_file( &self, isotope: &Isotope, library: EndfLibrary, mat: u32, ) -> Result<(PathBuf, String), EndfRetrievalError>
Retrieve the ENDF file for an isotope, using cache if available.
Returns the path to the cached ENDF file and its contents as a string.
§Arguments
isotope— The isotope to retrieve data for.library— The ENDF library to use.mat— The ENDF MAT (material) number.
Sourcepub fn peek_local_endf(
source: &Path,
) -> Result<(Isotope, String), EndfRetrievalError>
pub fn peek_local_endf( source: &Path, ) -> Result<(Isotope, String), EndfRetrievalError>
Peek a user-supplied ENDF source: decode the body and parse the HEAD record so the caller can route the upload to the correct isotope entry.
Accepts the same input forms as Self::install_local_endf — a raw
ENDF text file or the IAEA ZIP archive distribution — and returns the
isotope declared by the file’s MF=2 MT=151 HEAD record alongside the
decoded text. The GUI uses this to dispatch a manual upload to the
matching IsotopeEntry without re-reading or re-extracting the file
during install (issue #523, P2: avoid N-pass zip extraction).
Sourcepub fn install_endf_text(
&self,
isotope: &Isotope,
library: EndfLibrary,
text: &str,
) -> Result<PathBuf, EndfRetrievalError>
pub fn install_endf_text( &self, isotope: &Isotope, library: EndfLibrary, text: &str, ) -> Result<PathBuf, EndfRetrievalError>
Write already-validated ENDF text to the canonical cache slot for
isotope/library. Returns the cache file path.
Use this when the caller has already obtained text via
Self::peek_local_endf and confirmed the isotope. For one-shot
install-from-path, use Self::install_local_endf instead.
Sourcepub fn install_local_endf(
&self,
isotope: &Isotope,
library: EndfLibrary,
source: &Path,
) -> Result<(PathBuf, String), EndfRetrievalError>
pub fn install_local_endf( &self, isotope: &Isotope, library: EndfLibrary, source: &Path, ) -> Result<(PathBuf, String), EndfRetrievalError>
Install a user-supplied ENDF file into the cache for isotope/library.
Accepts either a raw ENDF text file (.endf, .dat, .txt, or
extensionless) or the IAEA ZIP archive distribution (n_…_….zip).
The file is parsed to verify that its declared isotope matches
isotope; on success the text is written to the canonical cache slot
returned by Self::cache_file_path and (cache_path, text) is
returned. Subsequent calls to Self::get_endf_file will then hit the
cache without any network access.
This is the GUI’s manual-upload escape hatch for users on networks where IAEA/NNDC is blocked (issue #523).