pub struct ArtifactSet { /* private fields */ }Expand description
An owned collection of relative FEFF workspace files.
The collection is suitable both for auxiliary inputs (spring.inp, CIF,
DYM, or included card files) and for generated output. Paths are always
relative and cannot contain . or .. components.
Implementations§
Source§impl ArtifactSet
impl ArtifactSet
Sourcepub fn insert(
&mut self,
path: impl Into<PathBuf>,
bytes: impl Into<Vec<u8>>,
) -> Result<Option<Vec<u8>>>
pub fn insert( &mut self, path: impl Into<PathBuf>, bytes: impl Into<Vec<u8>>, ) -> Result<Option<Vec<u8>>>
Insert or replace a file and return the previous payload, if any.
Sourcepub fn remove(&mut self, path: impl AsRef<Path>) -> Option<Vec<u8>>
pub fn remove(&mut self, path: impl AsRef<Path>) -> Option<Vec<u8>>
Remove one file by its relative path.
Sourcepub fn contains(&self, path: impl AsRef<Path>) -> bool
pub fn contains(&self, path: impl AsRef<Path>) -> bool
Return whether the workspace contains a path.
Sourcepub fn iter(&self) -> impl ExactSizeIterator<Item = ArtifactRef<'_>>
pub fn iter(&self) -> impl ExactSizeIterator<Item = ArtifactRef<'_>>
Iterate in stable path order.
Examples found in repository?
examples/benchmark.rs (line 26)
4fn main() -> Result<(), Box<dyn std::error::Error>> {
5 let args: Vec<_> = std::env::args().skip(1).collect();
6 if args.len() != 4 {
7 return Err("expected INPUT OUTPUT MODE THREADS".into());
8 }
9 let input = PathBuf::from(&args[0]);
10 let output = PathBuf::from(&args[1]);
11 let threads: usize = args[3].parse()?;
12 let mut runner = Runner::new();
13 if let Some(n) = NonZeroUsize::new(threads) {
14 runner = runner.with_threads(n);
15 }
16 let start = Instant::now();
17 let (stages, bytes) = if args[2] == "memory" || args[2] == "typed" {
18 if args[2] == "typed" {
19 runner = runner.with_artifacts(ArtifactSelection::None);
20 }
21 let result = runner.run_in_memory(MemoryRunRequest::new(std::fs::read(input)?))?;
22 (
23 result.report.stages.len(),
24 result
25 .artifacts
26 .iter()
27 .map(|file| file.bytes.len() as u64)
28 .sum::<u64>(),
29 )
30 } else {
31 let policy = if args[2] == "recompute" {
32 ExistingOutputPolicy::Recompute
33 } else {
34 ExistingOutputPolicy::ReuseValidated
35 };
36 let report = runner
37 .run_files(FileRunRequest::new(input, &output).with_existing_output_policy(policy))?;
38 let bytes = report
39 .artifacts
40 .iter()
41 .map(|path| std::fs::metadata(output.join(path)).map(|m| m.len()))
42 .collect::<Result<Vec<_>, _>>()?
43 .into_iter()
44 .sum::<u64>();
45 (report.stages.len(), bytes)
46 };
47 println!(
48 "{{\"seconds\":{},\"stages\":{},\"artifact_bytes\":{}}}",
49 start.elapsed().as_secs_f64(),
50 stages,
51 bytes
52 );
53 Ok(())
54}Trait Implementations§
Source§impl Clone for ArtifactSet
impl Clone for ArtifactSet
Source§fn clone(&self) -> ArtifactSet
fn clone(&self) -> ArtifactSet
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ArtifactSet
impl Debug for ArtifactSet
Source§impl Default for ArtifactSet
impl Default for ArtifactSet
Source§fn default() -> ArtifactSet
fn default() -> ArtifactSet
Returns the “default value” for a type. Read more
impl Eq for ArtifactSet
Source§impl PartialEq for ArtifactSet
impl PartialEq for ArtifactSet
impl StructuralPartialEq for ArtifactSet
Auto Trait Implementations§
impl Freeze for ArtifactSet
impl RefUnwindSafe for ArtifactSet
impl Send for ArtifactSet
impl Sync for ArtifactSet
impl Unpin for ArtifactSet
impl UnsafeUnpin for ArtifactSet
impl UnwindSafe for ArtifactSet
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
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> ⓘ
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 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> ⓘ
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