[][src]Struct bindle::Id

pub struct Id { /* fields omitted */ }

A parsed representation of an ID string for a bindle. This is currently defined as an arbitrary path with a version string at the end.

Examples of valid ID strings include:

  • foo/0.1.0
  • example.com/foo/1.2.3
  • example.com/a/longer/path/foo/1.10.0-rc.1

An Id can be parsed from any string using the .parse() method:

use bindle::Id;

let id: Id = "example.com/foo/1.2.3".parse().expect("should parse");
println!("{}", id);

An Id can also be parsed from any string using the TryFrom or TryInto trait:

use bindle::Id;
use std::convert::TryInto;

let id: Id = String::from("example.com/a/longer/path/foo/1.10.0-rc.1")
    .try_into().expect("should parse");
println!("{}", id);

Implementations

impl Id[src]

pub fn name(&self) -> &str[src]

Returns the name part of the ID

pub fn version(&self) -> &Version[src]

pub fn version_string(&self) -> String[src]

Returns the version part of the ID. This is returned as a String as it is a conversion from the underlying semver

pub fn sha(&self) -> String[src]

Returns the SHA256 sum of this Id for use as a common identifier

We don't typically want to store a bindle with its name and version number. This would impose both naming constraints on the bindle and security issues on the storage layout. So this function hashes the name/version data (which together MUST be unique in the system) and uses the resulting hash as the canonical name. The hash is guaranteed to be in the character set [a-zA-Z0-9].

Trait Implementations

impl Clone for Id[src]

impl Debug for Id[src]

impl<'de> Deserialize<'de> for Id[src]

impl Display for Id[src]

impl<'_> From<&'_ Id> for Id[src]

impl FromStr for Id[src]

type Err = ParseError

The associated error which can be returned from parsing.

impl Serialize for Id[src]

impl<'_> TryFrom<&'_ String> for Id[src]

type Error = ParseError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ str> for Id[src]

type Error = ParseError

The type returned in the event of a conversion error.

impl TryFrom<String> for Id[src]

type Error = ParseError

The type returned in the event of a conversion error.

Auto Trait Implementations

impl RefUnwindSafe for Id[src]

impl Send for Id[src]

impl Sync for Id[src]

impl Unpin for Id[src]

impl UnwindSafe for Id[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CloneAny for T where
    T: Clone + Any

impl<T> DebugAny for T where
    T: Any + Debug

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Typeable for T where
    T: Any

impl<T> UnsafeAny for T where
    T: Any

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