ndn_protocol/lib.rs
1#![warn(missing_docs)]
2//! Implements the core Named Data Networking (NDN) packet types -- [`Name`],
3//! [`Interest`], [`Data`], signatures, and certificates -- on top of the TLV
4//! encoding provided by [`ndn-tlv`](https://crates.io/crates/ndn-tlv).
5//!
6//! [`Name`] represents a hierarchical NDN name and can be built from a URI
7//! with [`Name::from_str`]. [`Interest`] and [`Data`] are the two packet
8//! types that make up NDN's request/response exchange; both are generic
9//! over their payload type so application data can be encoded and decoded
10//! through the same [`ndn_tlv::TlvEncode`]/[`ndn_tlv::TlvDecode`] traits
11//! used everywhere else in the stack. Signing and verifying either packet
12//! type goes through the [`SignMethod`](signature::SignMethod) and
13//! [`SignatureVerifier`](signature::SignatureVerifier) traits, with
14//! [`DigestSha256`] and [`SignatureSha256WithRsa`] as the two signature
15//! schemes implemented here.
16//!
17//! ```rust
18//! use ndn_protocol::{DigestSha256, Interest, Name, SignSettings};
19//!
20//! let mut interest = Interest::<()>::new(Name::from_str("/hello/world").unwrap());
21//! let mut signer = DigestSha256::new();
22//! interest.sign(&mut signer, SignSettings::default());
23//! assert!(interest.verify(&signer).is_ok());
24//! ```
25//!
26//! This crate implements the packet types themselves; it doesn't talk to a
27//! forwarder. [`ndn-app`](https://crates.io/crates/ndn-app) builds an
28//! application framework on top of these types.
29
30pub use data::{Content, ContentType, Data, FinalBlockId, FreshnessPeriod, MetaInfo};
31pub use interest::{
32 CanBePrefix, ForwardingHint, HopLimit, Interest, InterestLifetime, MustBeFresh, Nonce,
33 SignSettings,
34};
35pub use name::{
36 GenericNameComponent, ImplicitSha256DigestComponent, Name, NameComponent, OtherNameComponent,
37};
38pub use signature::{
39 DigestSha256, KeyDigest, KeyLocator, SignatureInfo, SignatureSha256WithRsa, SignatureType,
40 SignatureValue,
41};
42
43pub use certificate::{Certificate, RsaCertificate, SafeBag};
44
45pub mod certificate;
46pub mod data;
47pub mod error;
48pub mod interest;
49pub mod name;
50pub mod signature;