Skip to main content

nk_core/
lib.rs

1#![cfg_attr(feature = "os-rng", doc = include_str!("../README.md"))]
2#![cfg_attr(
3    not(feature = "os-rng"),
4    doc = "`nk-core` is the leaf protocol crate: a platform-neutral (`no_std` + `alloc`, sans-IO) implementation of the nostr wire protocol — NIP-01 core types plus every supported NIP module, verified byte-for-byte against `@qntx/nostr` through shared vectors. Build with the `os-rng` feature for the full crate guide."
5)]
6#![forbid(unsafe_code)]
7#![no_std]
8#![cfg_attr(docsrs, feature(doc_cfg))]
9
10extern crate alloc;
11
12#[cfg(feature = "std")]
13extern crate std;
14
15pub use rand_core;
16
17#[cfg(feature = "os-rng")]
18pub use getrandom::SysRng;
19
20pub mod limits;
21
22pub mod event;
23pub mod filter;
24pub(crate) mod hex;
25pub(crate) mod json;
26pub mod key;
27pub mod message;
28pub mod time;
29pub mod url;
30
31pub mod nips;
32pub mod signer;
33
34#[cfg(test)]
35pub(crate) mod testutil;
36
37pub use event::{
38    Coordinate, DeletionTarget, Event, EventBuilder, EventId, Kind, KindClass, Metadata, Tag, Tags,
39    UnsignedEvent,
40};
41pub use filter::{Filter, SingleLetterTag, fingerprint};
42pub use json::JsonError;
43pub use key::{Keys, PublicKey, SecretKey, Signature};
44pub use message::{ClientMessage, CountResult, Hll, RelayMessage, SubscriptionId};
45pub use signer::{BoxFuture, NostrSigner, SignerBackendError, SignerError};
46pub use time::Timestamp;
47pub use url::RelayUrl;
48
49// `criterion` is a dev-dependency consumed only by `benches/`; without this
50// import the lib-test target reports it unused.
51#[cfg(test)]
52use criterion as _;
53
54const _: () = {
55    const fn assert_send_sync<T: Send + Sync>() {}
56    assert_send_sync::<ClientMessage<'static>>();
57    assert_send_sync::<Coordinate>();
58    assert_send_sync::<CountResult>();
59    assert_send_sync::<DeletionTarget>();
60    assert_send_sync::<Event>();
61    assert_send_sync::<EventBuilder>();
62    assert_send_sync::<EventId>();
63    assert_send_sync::<Filter>();
64    assert_send_sync::<Hll>();
65    assert_send_sync::<JsonError>();
66    assert_send_sync::<Kind>();
67    assert_send_sync::<KindClass>();
68    assert_send_sync::<Keys>();
69    assert_send_sync::<Metadata>();
70    assert_send_sync::<PublicKey>();
71    assert_send_sync::<RelayMessage<'static>>();
72    assert_send_sync::<RelayUrl>();
73    assert_send_sync::<SecretKey>();
74    assert_send_sync::<Signature>();
75    assert_send_sync::<SingleLetterTag>();
76    assert_send_sync::<SubscriptionId>();
77    assert_send_sync::<Tag>();
78    assert_send_sync::<Tags>();
79    assert_send_sync::<Timestamp>();
80    assert_send_sync::<UnsignedEvent>();
81};