summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2018-01-24 14:17:39 +0100
committerJustus Winter <justus@sequoia-pgp.org>2018-01-24 14:17:39 +0100
commit3956b4d7f0512a3014192c4b79274caf7eaadc66 (patch)
treee43bb94ac89bd7d8fec89972870ee76381aa6e58 /src/lib.rs
parentf558a177fa7adbb2d609e081571bfeefeac87118 (diff)
Add an example to the toplevel crate.
- We should replace this with a more comprehensive example covering the other crates too.
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 8040fbfb..0c536277 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2,7 +2,33 @@
//!
//! Sequoia consists of several modules. This crate conveniently
//! re-exports the other crates.
+//!
+//! # Example
+//!
+//! ```
+//! use std::io::Read;
+//! #[macro_use] extern crate openpgp;
+//! use openpgp::armor;
+//! # use std::io::Result;
+//! # fn main() { f().unwrap(); }
+//! # fn f() -> Result<()> {
+//!
+//! let mut reader = armored!(
+//! "-----BEGIN PGP ARMORED FILE-----
+//!
+//! SGVsbG8gd29ybGQh
+//! =s4Gu
+//! -----END PGP ARMORED FILE-----"
+//! );
+//!
+//! let mut content = String::new();
+//! reader.read_to_string(&mut content)?;
+//! assert_eq!(content, "Hello world!");
+//! # Ok(())
+//! # }
+//! ```
+// XXX: It would be nice to re-export the macros too.
pub extern crate openpgp;
pub extern crate sequoia_core as core;
pub extern crate sequoia_net as net;