Enum guppy::platform::PlatformSpecSummary
source · pub enum PlatformSpecSummary {
Always,
Platform(PlatformSummary),
Any,
}
summaries
only.Expand description
A serializable version of PlatformSpec
.
Requires the summaries
feature to be enabled.
Variants§
Always
The intersection of all platforms.
This is converted to and from PlatformSpec::Always
, and is expressed as the string
"always"
, or as spec = "always"
.
Examples
Deserialize the string "always"
.
let spec: PlatformSpecSummary = serde_json::from_str(r#""always""#).unwrap();
assert_eq!(spec, PlatformSpecSummary::Always);
Deserialize spec = "always"
.
let spec: PlatformSpecSummary = toml::from_str(r#"spec = "always""#).unwrap();
assert_eq!(spec, PlatformSpecSummary::Always);
Platform(PlatformSummary)
An individual platform.
This is converted to and from PlatformSpec::Platform
, and is serialized as the platform
itself (either a triple string, or a map such as
{ triple = "x86_64-unknown-linux-gnu", target-features = [] }
).
Examples
Deserialize a target triple.
let spec: PlatformSpecSummary = serde_json::from_str(r#""x86_64-unknown-linux-gnu""#).unwrap();
assert_eq!(
spec,
PlatformSpecSummary::Platform(PlatformSummary::new("x86_64-unknown-linux-gnu")),
);
Deserialize a target map.
let spec: PlatformSpecSummary = toml::from_str(r#"
triple = "x86_64-unknown-linux-gnu"
target-features = []
flags = []
"#).unwrap();
assert_eq!(
spec,
PlatformSpecSummary::Platform(
PlatformSummary::new("x86_64-unknown-linux-gnu")
.with_target_features(TargetFeaturesSummary::Features(BTreeSet::new()))
)
);
Any
The union of all platforms.
This is converted to and from PlatformSpec::Any
, and is serialized as the string
"any"
.
This is also the default, since in many cases one desires to compute the union of enabled dependencies across all platforms.
Examples
Deserialize the string "any"
.
let spec: PlatformSpecSummary = serde_json::from_str(r#""any""#).unwrap();
assert_eq!(spec, PlatformSpecSummary::Any);
Deserialize spec = "any"
.
let spec: PlatformSpecSummary = toml::from_str(r#"spec = "any""#).unwrap();
assert_eq!(spec, PlatformSpecSummary::Any);
Implementations§
source§impl PlatformSpecSummary
impl PlatformSpecSummary
sourcepub fn new(platform_spec: &PlatformSpec) -> Self
pub fn new(platform_spec: &PlatformSpec) -> Self
Creates a new PlatformSpecSummary
from a PlatformSpec
.
sourcepub fn to_platform_spec(&self) -> Result<PlatformSpec, TargetSpecError>
pub fn to_platform_spec(&self) -> Result<PlatformSpec, TargetSpecError>
Converts self
to a PlatformSpec
.
Returns an Error
if the platform was unknown.
Trait Implementations§
source§impl Clone for PlatformSpecSummary
impl Clone for PlatformSpecSummary
source§fn clone(&self) -> PlatformSpecSummary
fn clone(&self) -> PlatformSpecSummary
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PlatformSpecSummary
impl Debug for PlatformSpecSummary
source§impl Default for PlatformSpecSummary
impl Default for PlatformSpecSummary
source§fn default() -> PlatformSpecSummary
fn default() -> PlatformSpecSummary
source§impl<'de> Deserialize<'de> for PlatformSpecSummary
impl<'de> Deserialize<'de> for PlatformSpecSummary
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 PartialEq<PlatformSpecSummary> for PlatformSpecSummary
impl PartialEq<PlatformSpecSummary> for PlatformSpecSummary
source§fn eq(&self, other: &PlatformSpecSummary) -> bool
fn eq(&self, other: &PlatformSpecSummary) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for PlatformSpecSummary
impl Serialize for PlatformSpecSummary
impl Eq for PlatformSpecSummary
impl StructuralEq for PlatformSpecSummary
impl StructuralPartialEq for PlatformSpecSummary
Auto Trait Implementations§
impl RefUnwindSafe for PlatformSpecSummary
impl Send for PlatformSpecSummary
impl Sync for PlatformSpecSummary
impl Unpin for PlatformSpecSummary
impl UnwindSafe for PlatformSpecSummary
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<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.