Struct confitul::HostInfo

source ·
pub struct HostInfo {
    pub id: HostId,
    pub name: String,
    pub description: String,
    pub urls: Vec<Url>,
    pub sig: Option<Vec<u8>>,
}
Expand description

HostInfo corresponds to an aggregation of nodes, running within a same program instance. Think of them as “physical”, macro entities, as opposed to nodes which are much more virtual and small. A given host will typically have several nodes to power, all of them going through the same addresses (http etc.).

Fields§

§id: HostId

ID used by the host. This happens to be the public key as well, when it comes to signing messages.

§name: String

Name of the host, a free-form test, by default the hostname.

§description: String

Description of the host, a free-form text.

§urls: Vec<Url>

URLs of the host, how to connect to it.

§sig: Option<Vec<u8>>

Signature of the host info.

Implementations§

Examples found in repository?
src/host.rs (line 130)
129
130
131
    fn verify_self(&self) -> Result<(), signature::Error> {
        self.verify_msg(&self.info().content_to_verify(), &self.sig())
    }
More examples
Hide additional examples
src/local_host.rs (line 60)
59
60
61
62
    fn update_sig(&mut self) {
        let sig = sign(&self.keypair, &self.info.content_to_verify());
        self.info.sig = Some(sig);
    }

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
Deserialize this value from the given Serde deserializer. Read more

Pretty-print a host.

Examples
use confitul::HostInfo;
use confitul::HostId;
use ed25519_dalek::Keypair;
use rand07::rngs::OsRng;
use url::Url;
use std::convert::TryFrom;

let mut csprng = OsRng {};
let keypair: Keypair = Keypair::generate(&mut csprng);

let h = HostInfo {
    id: HostId::new(&keypair),
    name: String::from("computer"),
    description: String::from("test"),
    urls: vec![Url::parse("http://localhost").unwrap()],
    sig: None,
};
assert_eq!("{\"id\":\"0x", &format!("{}", h)[0..9]);
assert_eq!("\",\"name\":\"computer\",\"description\":\"test\",\"urls\":[\"http://localhost/\"]}", &format!("{}", h)[18..88]);
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
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
Converts the given value to a String. 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.