Sitelet https://docs.rs/refeff/latest/refeff/struct.ArtifactSet.html
Skip to main content

ArtifactSet

Struct ArtifactSet 

Source
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

Source

pub const fn new() -> Self

Create an empty workspace.

Source

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.

Source

pub fn get(&self, path: impl AsRef<Path>) -> Option<&[u8]>

Read one file by its relative path.

Source

pub fn remove(&mut self, path: impl AsRef<Path>) -> Option<Vec<u8>>

Remove one file by its relative path.

Source

pub fn contains(&self, path: impl AsRef<Path>) -> bool

Return whether the workspace contains a path.

Source

pub fn len(&self) -> usize

Number of files in the workspace.

Source

pub fn is_empty(&self) -> bool

Return whether the workspace contains no files.

Source

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

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for ArtifactSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ArtifactSet

Source§

fn default() -> ArtifactSet

Returns the “default value” for a type. Read more
Source§

impl Eq for ArtifactSet

Source§

impl PartialEq for ArtifactSet

Source§

fn eq(&self, other: &ArtifactSet) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ArtifactSet

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

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

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

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

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

Source§

fn vzip(self) -> V