Skip to main content

Module encode

Module encode 

Source
Expand description

Support for encoding the network document meta-format

Implements writing documents according to dir-spec.txt. section 1.2 and 1.3.

This facility processes output that complies with the meta-document format, (dir-spec.txt section 1.2) - unless raw methods are called with improper input.

However, no checks are done on keyword presence/absence, multiplicity, or ordering, so the output may not necessarily conform to the format of the particular intended document. It is the caller’s responsibility to call .item() in the right order, with the right keywords and arguments.

Re-exportsΒ§

use std::cmp; πŸ”’
use std::collections::BTreeSet; πŸ”’
use std::fmt::Write; πŸ”’
use std::iter; πŸ”’
use std::marker::PhantomData; πŸ”’
use std::sync::Arc; πŸ”’
use base64ct::Base64; πŸ”’
use base64ct::Base64Unpadded; πŸ”’
use base64ct::Encoding; πŸ”’
use educe::Educe; πŸ”’
use itertools::Itertools; πŸ”’
use paste::paste; πŸ”’
use rand::CryptoRng; πŸ”’
use rand::Rng; πŸ”’
use tor_bytes::EncodeError; πŸ”’
use tor_error::internal; πŸ”’
use void::Void; πŸ”’
use crate::KeywordEncodable; πŸ”’
use crate::parse::tokenize::tag_keywords_ok; πŸ”’
use crate::types::misc::Iso8601TimeSp; πŸ”’

ModulesΒ§

derive πŸ”’
Deriving NetdocEncodable
impls πŸ”’
Implementations of our useful traits, on external and parsing-mode types
multiplicity πŸ”’
Multiplicity for encoding netdoc elements, via ad-hoc deref specialisation.

MacrosΒ§

item_value_encodable_for_tuple πŸ”’
implement ItemValueEncodable for a particular tuple size

StructsΒ§

Cursor
Position within a (perhaps partially-) built document
ItemEncoder
Encoder for an individual item within a being-built document
NetdocEncoder
Encoder, representing a partially-built document.

TraitsΒ§

EncodeOrd
Ordering, to be used when encoding network documents
ItemArgument
Types that can be added as argument(s) to item keyword lines
ItemObjectEncodable
An Object value that be encoded into a netdoc
ItemValueEncodable
Items that can be encoded in network documents
NetdocBuilder
Builders for network documents.
NetdocEncodable
Documents (or sub-documents) that can be encoded in the netdoc metaformat
NetdocEncodableFields
Collections of fields that can be encoded in the netdoc metaformat

FunctionsΒ§

encode_netdoc_fields
Encode a collection of fields (a document without an intro item) into a String
encode_netdoc_unsigned
Encode one or more whole (unsigned) network documents into a String