pub enum PlatformSpecSummary {
    Always,
    Platform(PlatformSummary),
    Any,
}
Available on crate feature 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 {
    triple: "x86_64-unknown-linux-gnu".to_owned(),
    target_features: TargetFeaturesSummary::Unknown,
    flags: BTreeSet::new(),
}));

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 {
    triple: "x86_64-unknown-linux-gnu".to_owned(),
    target_features: TargetFeaturesSummary::Features(BTreeSet::new()),
    flags: 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§

Creates a new PlatformSpecSummary from a PlatformSpec.

Converts self to a PlatformSpec.

Returns an Error if the platform was unknown.

Returns true if self is PlatformSpecSummary::Any.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.