Download Dataset_Construction/projects/libp2p/rust/misc/server/src/config.rs from SYSUSELab/RustRepoTrans: direct link, hf CLI and curl.
- Browser
- Download file 966 Bytes
-
https://huggingface.co/datasets/SYSUSELab/RustRepoTrans/resolve/main/Dataset_Construction/projects/libp2p/rust/misc/server/src/config.rs
- Command line
-
hf download hf://datasets/SYSUSELab/RustRepoTrans/Dataset_Construction/projects/libp2p/rust/misc/server/src/config.rs
-
curl -L -o config.rs https://huggingface.co/datasets/SYSUSELab/RustRepoTrans/resolve/main/Dataset_Construction/projects/libp2p/rust/misc/server/src/config.rs
966 Bytes
| use libp2p::Multiaddr; | |
| use serde_derive::Deserialize; | |
| use std::error::Error; | |
| use std::path::Path; | |
| pub(crate) struct Config { | |
| pub(crate) identity: Identity, | |
| pub(crate) addresses: Addresses, | |
| } | |
| impl Config { | |
| pub(crate) fn from_file(path: &Path) -> Result<Self, Box<dyn Error>> { | |
| Ok(serde_json::from_str(&std::fs::read_to_string(path)?)?) | |
| } | |
| } | |
| pub(crate) struct Identity { | |
| pub(crate) peer_id: String, | |
| pub(crate) priv_key: String, | |
| } | |
| pub(crate) struct Addresses { | |
| pub(crate) swarm: Vec<Multiaddr>, | |
| pub(crate) append_announce: Vec<Multiaddr>, | |
| } | |
| impl zeroize::Zeroize for Config { | |
| fn zeroize(&mut self) { | |
| self.identity.peer_id.zeroize(); | |
| self.identity.priv_key.zeroize(); | |
| } | |
| } | |