use std::collections::HashMap; use crate::types::util::IPFSHash; use crate::types::util::IPNSHash; pub struct App { repo: Repository, profile: Profile, publishing_key: String } impl App { pub fn load(profile: Profile, publishing_key: String, host: &str, port: u16) -> Result { Repository::new(host, port).map(|repo| App { repo, profile, publishing_key }) } pub async fn new_profile(repo: Repository, names: Vec) -> Result { let payload = Payload::Profile { names, picture: None, more: BTreeMap::new(), }; let timestamp = types::Timestamp::now(); let content = Content::new(vec![], timestame, payload); let head = repository.put_content(content).await?; let device_name = repository.publish(&publishing_key, &head).await?; let profile = Profile { device_name, devices: vec![], }; Ok(App { repository, profile, publishing_key }) } }