pub struct Outputs(OutputsInner);Expand description
Derivation outputs with filled out StorePath.
Each output has an OutputName and a StorePath and Outputs
provides a map of OutputName to StorePath to provide easy
access while still maintaining invariants.
In general there are two types of outputs: fixed or input addressed.
And while the fixed output also has a name and a StorePath it
addtionally also has a OutputHash.
§Invariants
- Only a single FOD output is allowed and it must be named
out - Duplicately named outputs is an error
- Outputs can not be empty
Tuple Fields§
§0: OutputsInnerImplementations§
Source§impl Outputs
impl Outputs
Sourcepub fn fixed_output(output_hash: OutputHash, store_path: StorePath) -> Self
pub fn fixed_output(output_hash: OutputHash, store_path: StorePath) -> Self
Create Outputs with a fixed output with provided output_hash and store_path.
This single fixed output is always named out.
Sourcepub fn input_addressed_from_iter<I>(it: I) -> Result<Self, OutputsError>
pub fn input_addressed_from_iter<I>(it: I) -> Result<Self, OutputsError>
Try to create input addressed Outputs from the provided iterator.
This will return a OutputsError if the OutputName, StorePath pairs
in the iterator don’t follow the invariants.
Sourcepub fn try_from_iter<I>(it: I) -> Result<Self, OutputsError>
pub fn try_from_iter<I>(it: I) -> Result<Self, OutputsError>
Try to make Outputs from the provided iterator.
This will return a OutputsError if the OutputName, StorePath, OutputHash tuple
in the iterator don’t follow the invariants.
Sourcepub fn as_fixed_output_hash(&self) -> Option<&OutputHash>
pub fn as_fixed_output_hash(&self) -> Option<&OutputHash>
Return output hash if this Outputs is fixed.
Sourcepub fn as_fixed_output(&self) -> Option<(&OutputHash, &StorePath)>
pub fn as_fixed_output(&self) -> Option<(&OutputHash, &StorePath)>
Return output hash and store path if this Outputs is fixed.
Sourcepub fn into_builder(self) -> OutputsBuilder
pub fn into_builder(self) -> OutputsBuilder
Convert this Outputs into an OutputsBuilder with the same type and output names.
Sourcepub fn into_unverified_builder(self) -> UnverifiedOutputsBuilder
pub fn into_unverified_builder(self) -> UnverifiedOutputsBuilder
Convert this Outputs into an OutputsBuilder with the same type and output names.
Sourcepub fn contains_key(&self, name: &OutputName) -> bool
pub fn contains_key(&self, name: &OutputName) -> bool
Returns true if the outputs contains an output with the specified name.
Sourcepub fn get(&self, name: &OutputName) -> Option<&StorePath>
pub fn get(&self, name: &OutputName) -> Option<&StorePath>
Returns a reference to the StorePath corresponding to the provided name.
Sourcepub fn iter(&self) -> Iter<'_> ⓘ
pub fn iter(&self) -> Iter<'_> ⓘ
Gets an iterator over the entries of the outputs, sorted by name.
Sourcepub fn names(&self) -> OutputNames<'_> ⓘ
pub fn names(&self) -> OutputNames<'_> ⓘ
Gets an iterator over the names of the outputs, in sorted order.
§Examples
use nix_compat::derivation::{Outputs, OutputName};
use nix_compat::store_path::StorePath;
let out_sp : StorePath = "2vixb94v0hy2xc6p7mbnxxcyc095yyia-has-multi-out".parse().unwrap();
let bin_sp : StorePath = "2vixb94v0hy2xc6p7mbnxxcyc095yyib-has-multi-out-bin".parse().unwrap();
let a = Outputs::input_addressed_from_iter([
(OutputName::out(), out_sp),
(OutputName::from_static("bin").unwrap(), bin_sp),
]).expect("multiple outputs");
let names: Vec<OutputName> = a.names().cloned().collect();
assert_eq!(names, [
OutputName::from_static("bin").unwrap(),
OutputName::out(),
]);Sourcepub fn into_names(self) -> IntoOutputNames ⓘ
pub fn into_names(self) -> IntoOutputNames ⓘ
Convert this Outputs to an iterator over the names of the outputs, in sorted order.
Sourcepub fn store_paths(&self) -> impl Iterator<Item = &StorePath>
pub fn store_paths(&self) -> impl Iterator<Item = &StorePath>
Gets an iterator over the StorePath values of the outputs, in order by name.
§Examples
use nix_compat::derivation::{Outputs, OutputName};
use nix_compat::store_path::StorePath;
let out_sp : StorePath = "2vixb94v0hy2xc6p7mbnxxcyc095yyia-has-multi-out".parse().unwrap();
let a = Outputs::input_addressed_from_iter([(OutputName::out(), out_sp.clone())]).unwrap();
let values: Vec<StorePath> = a.store_paths().cloned().collect();
assert_eq!(values, [out_sp]);Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of outputs
§Examples
use nix_compat::derivation::{Outputs, OutputName};
use nix_compat::store_path::StorePath;
let out_sp : StorePath = "2vixb94v0hy2xc6p7mbnxxcyc095yyia-has-multi-out".parse().unwrap();
let a = Outputs::input_addressed_from_iter([(OutputName::out(), out_sp.clone())]).unwrap();
assert_eq!(a.len(), 1);
let bin_sp : StorePath = "2vixb94v0hy2xc6p7mbnxxcyc095yyib-has-multi-out-bin".parse().unwrap();
let b = Outputs::input_addressed_from_iter([
(OutputName::out(), out_sp),
(OutputName::from_static("bin").unwrap(), bin_sp),
]).expect("multiple outputs");
assert_eq!(b.len(), 2);Sourcepub fn is_single(&self) -> bool
pub fn is_single(&self) -> bool
Returns true if this contains only a single output.
§Examples
use nix_compat::derivation::{Outputs, OutputName};
use nix_compat::store_path::StorePath;
let out_sp : StorePath = "2vixb94v0hy2xc6p7mbnxxcyc095yyia-has-multi-out".parse().unwrap();
let a = Outputs::fixed_output(output_hash, out_sp.clone());
assert!(a.is_single());
let b = Outputs::input_addressed_from_iter([(OutputName::out(), out_sp.clone())]).unwrap();
assert!(b.is_single());
let bin_sp : StorePath = "2vixb94v0hy2xc6p7mbnxxcyc095yyib-has-multi-out-bin".parse().unwrap();
let c = Outputs::input_addressed_from_iter([
(OutputName::out(), out_sp),
(OutputName::from_static("bin").unwrap(), bin_sp),
]).unwrap();
assert!(!c.is_single());Sourcepub fn is_fixed(&self) -> bool
pub fn is_fixed(&self) -> bool
Returns true if this is a single fixed-output.
§Examples
use nix_compat::derivation::{Outputs, OutputName};
use nix_compat::store_path::StorePath;
let out_sp : StorePath = "2vixb94v0hy2xc6p7mbnxxcyc095yyia-has-multi-out".parse().unwrap();
let a = Outputs::fixed_output(output_hash, out_sp.clone());
assert!(a.is_fixed());
let b = Outputs::input_addressed_from_iter([(OutputName::out(), out_sp.clone())]).unwrap();
assert!(!b.is_fixed());
let bin_sp : StorePath = "2vixb94v0hy2xc6p7mbnxxcyc095yyib-has-multi-out-bin".parse().unwrap();
let c = Outputs::input_addressed_from_iter([
(OutputName::out(), out_sp),
(OutputName::from_static("bin").unwrap(), bin_sp),
]).unwrap();
assert!(!c.is_fixed());Sourcepub fn is_input_addressed(&self) -> bool
pub fn is_input_addressed(&self) -> bool
Returns true if this is a set of input addressed outputs.
Trait Implementations§
Source§impl AtermWriteable for Outputs
impl AtermWriteable for Outputs
Source§impl<'de> Deserialize<'de> for Outputs
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Outputs
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl From<Outputs> for OutputsBuilder
impl From<Outputs> for OutputsBuilder
Source§impl From<Outputs> for UnverifiedOutputsBuilder
impl From<Outputs> for UnverifiedOutputsBuilder
Source§impl<'a> IntoIterator for &'a Outputs
impl<'a> IntoIterator for &'a Outputs
Source§impl IntoIterator for Outputs
impl IntoIterator for Outputs
Source§impl NixDeserialize for Outputs
Available on crate features wire and nix-compat-derive only.
impl NixDeserialize for Outputs
wire and nix-compat-derive only.Source§impl NixSerialize for Outputs
Available on crate features wire and nix-compat-derive only.
impl NixSerialize for Outputs
wire and nix-compat-derive only.Source§impl PartialEq<Outputs> for OutputsBuilder
impl PartialEq<Outputs> for OutputsBuilder
Source§impl PartialEq<OutputsBuilder> for Outputs
impl PartialEq<OutputsBuilder> for Outputs
Source§fn eq(&self, other: &OutputsBuilder) -> bool
fn eq(&self, other: &OutputsBuilder) -> bool
self and other values to be equal, and is used by ==.impl Eq for Outputs
impl StructuralPartialEq for Outputs
Auto Trait Implementations§
impl Freeze for Outputs
impl RefUnwindSafe for Outputs
impl Send for Outputs
impl Sync for Outputs
impl Unpin for Outputs
impl UnsafeUnpin for Outputs
impl UnwindSafe for Outputs
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.