summaryrefslogtreecommitdiff
path: root/src/tag.rs
diff options
context:
space:
mode:
authorStuart Stock <stuart@int08h.com>2017-06-19 22:01:46 -0500
committerStuart Stock <stuart@int08h.com>2017-06-19 22:01:46 -0500
commitdc17df4885cef546ed44d14a291ba782b82d93ed (patch)
tree8a593164f7d678fcae4501945891eb8bfcb3cfa6 /src/tag.rs
parent13d53fec92fddae9c312d323db81bbcb97adbe21 (diff)
downloadroughenough-dc17df4885cef546ed44d14a291ba782b82d93ed.zip
begin work on server
Diffstat (limited to 'src/tag.rs')
-rw-r--r--src/tag.rs35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/tag.rs b/src/tag.rs
index 168d81a..b50f5f5 100644
--- a/src/tag.rs
+++ b/src/tag.rs
@@ -1,25 +1,32 @@
+
+/// An unsigned 32-bit value (key) that maps to a byte-string (value).
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd)]
pub enum Tag {
- CERT,
- DELE,
- INDX,
- MAXT,
- MIDP,
- MINT,
- NONC,
- PAD,
- PATH,
- PUBK,
- RADI,
- ROOT,
- SIG,
+ // Enforcement of the "tags in strictly increasing order" rule is done using the
+ // little-endian encoding of the ASCII tag value; e.g. 'SIG\x00' is 0x00474953 and
+ // 'NONC' is 0x434e4f4e. The tags are listed here is reverse lexical order which
+ // matches the little-endian comparison order.
SREP,
+ SIG,
+ ROOT,
+ RADI,
+ PUBK,
+ PATH,
+ PAD,
+ NONC,
+ MINT,
+ MIDP,
+ MAXT,
+ INDX,
+ DELE,
+ CERT,
}
static PAD_VALUE: [u8; 4] = [b'P', b'A', b'D', 0x00];
static SIG_VALUE: [u8; 4] = [b'S', b'I', b'G', 0xff];
impl Tag {
+ /// Translates a tag into its on-the-wire representation
pub fn wire_value(&self) -> &'static [u8] {
match *self {
Tag::CERT => "CERT".as_bytes(),
@@ -29,7 +36,7 @@ impl Tag {
Tag::MIDP => "MIDP".as_bytes(),
Tag::MINT => "MINT".as_bytes(),
Tag::NONC => "NONC".as_bytes(),
- Tag::PAD => PAD_VALUE.as_ref(),
+ Tag::PAD => PAD_VALUE.as_ref(),
Tag::PATH => "PATH".as_bytes(),
Tag::PUBK => "PUBK".as_bytes(),
Tag::RADI => "RADI".as_bytes(),