drand_core 0.0.19

A drand client library.
Documentation
//! # drand-core
//!
//! drand-core is a library to retrieve public randomness generated by drand beacons. It features an HTTP client, and verification method.
//!
//! The format specification is at [drand.love/docs/specification](https://drand.love/docs/specification/). drand was designed in [Scalable Bias-Resistant Distributed Randomness](https://eprint.iacr.org/2016/1067.pdf).
//!
//! The reference interroperable Go implementation is available at [drand/drand](https://github.com/drand/drand).
//!
//! ## Usage
//!
#![cfg_attr(
    not(target_arch = "wasm32"),
    doc = r#"
```rust
use drand_core::HttpClient;

// Create a new client
let client: HttpClient = "https://drand.cloudflare.com".try_into().unwrap();

// Get the latest beacon. By default, it verifies its signature against the chain info.
let beacon = client.latest().unwrap();

// Print the beacon
println!("{:?}", beacon);
```
"#
)]

pub mod beacon;
mod bls_signatures;
pub mod chain;
pub use chain::ChainOptions;
#[cfg(not(target_arch = "wasm32"))]
mod http_client;
#[cfg(not(target_arch = "wasm32"))]
pub use http_client::HttpClient;
use thiserror::Error;

#[derive(Error, Debug)]
pub enum DrandError {
    #[error(transparent)]
    Beacon(#[from] Box<beacon::BeaconError>),
    #[cfg(not(target_arch = "wasm32"))]
    #[error(transparent)]
    HTTPClient(#[from] Box<http_client::HttpClientError>),
    #[error(transparent)]
    Signature(#[from] Box<bls_signatures::VerificationError>),
}

type Result<T> = std::result::Result<T, DrandError>;