#![doc = include_str!("../README.md")]
#[macro_use]
extern crate tracing;
pub mod api;
pub mod chunk;
pub mod endpoint;
pub mod frame;
pub mod rt;
pub mod types;
use ed25519_dalek::{PublicKey, SecretKey};
use rand::rngs::OsRng;
pub use types::error::{
BlockError, ClientError, EncodingError, MicroframeError, NetmodError, NonfatalError,
RatmanError, Result, ScheduleError,
};
#[cfg(feature = "daemon")]
pub use axum;
#[cfg(feature = "daemon")]
pub use axum_embed;
pub use futures;
pub use hex;
pub use tokio;
pub use tokio_stream;
pub use tokio_util;
use types::{Address, Ident32};
pub fn elog<S: Into<String>>(msg: S, code: u16) -> ! {
error!("{}", msg.into());
std::process::exit(code.into());
}
pub fn env_xdg_data() -> Option<String> {
std::env::var("XDG_DATA_HOME").ok()
}
pub fn env_xdg_config() -> Option<String> {
std::env::var("XDG_CONFIG_HOME").ok()
}
pub fn generate_space_key() -> (Address, Ident32) {
let secret_key = SecretKey::generate(&mut OsRng {});
let public_key = PublicKey::from(&secret_key);
let space_key = Ident32::from_bytes(secret_key.as_bytes());
let space_addr = Address::from_bytes(public_key.as_bytes());
(space_addr, space_key)
}