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: HostIdID used by the host. This happens to be the public key as well, when it comes to signing messages.
name: StringName of the host, a free-form test, by default the hostname.
description: StringDescription 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§
source§impl HostInfo
impl HostInfo
sourcepub fn content_to_verify(&self) -> Vec<u8> ⓘ
pub fn content_to_verify(&self) -> Vec<u8> ⓘ
Examples found in repository?
More examples
Trait Implementations§
source§impl<'de> Deserialize<'de> for HostInfo
impl<'de> Deserialize<'de> for HostInfo
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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for HostInfo
impl Display for HostInfo
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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]);