Struct auditable_serde::VersionInfo
source · pub struct VersionInfo {
pub packages: Vec<Package>,
}
Expand description
Dependency tree embedded in the binary.
Implements Serialize
and Deserialize
traits from serde
, so you can use
all the usual methods from serde-json
to read and write it.
from_str()
that parses JSON is also implemented for your convenience:
use auditable_serde::VersionInfo;
use std::str::FromStr;
let json_str = r#"{"packages":[{
"name":"adler",
"version":"0.2.3",
"source":"registry"
}]}"#;
let info = VersionInfo::from_str(json_str).unwrap();
assert_eq!(&info.packages[0].name, "adler");
If deserialization succeeds, it is guaranteed that there is only one root package, and that are no cyclic dependencies.
§Optional features
If the from_metadata
feature is enabled, a conversion from
cargo_metadata::Metadata
is possible via the TryFrom
trait. This is the preferred way to construct this structure.
An example demonstrating that can be found
here.
If the toml
feature is enabled, a conversion into the cargo_lock::Lockfile
struct is possible via the TryFrom
trait. This can be useful if you need to interoperate with tooling
that consumes the Cargo.lock
file format. An example demonstrating it can be found
here.
Fields§
§packages: Vec<Package>
Trait Implementations§
source§impl Clone for VersionInfo
impl Clone for VersionInfo
source§fn clone(&self) -> VersionInfo
fn clone(&self) -> VersionInfo
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for VersionInfo
impl Debug for VersionInfo
source§impl<'de> Deserialize<'de> for VersionInfo
impl<'de> Deserialize<'de> for VersionInfo
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 FromStr for VersionInfo
impl FromStr for VersionInfo
source§impl JsonSchema for VersionInfo
impl JsonSchema for VersionInfo
source§fn schema_name() -> String
fn schema_name() -> String
source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moresource§impl Ord for VersionInfo
impl Ord for VersionInfo
source§fn cmp(&self, other: &VersionInfo) -> Ordering
fn cmp(&self, other: &VersionInfo) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for VersionInfo
impl PartialEq for VersionInfo
source§fn eq(&self, other: &VersionInfo) -> bool
fn eq(&self, other: &VersionInfo) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for VersionInfo
impl PartialOrd for VersionInfo
source§fn partial_cmp(&self, other: &VersionInfo) -> Option<Ordering>
fn partial_cmp(&self, other: &VersionInfo) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for VersionInfo
impl Serialize for VersionInfo
source§impl TryFrom<&Metadata> for VersionInfo
impl TryFrom<&Metadata> for VersionInfo
source§impl TryFrom<&VersionInfo> for Lockfile
impl TryFrom<&VersionInfo> for Lockfile
impl Eq for VersionInfo
impl StructuralPartialEq for VersionInfo
Auto Trait Implementations§
impl RefUnwindSafe for VersionInfo
impl Send for VersionInfo
impl Sync for VersionInfo
impl Unpin for VersionInfo
impl UnwindSafe for VersionInfo
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
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.