1
#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg))]
2
#![doc = include_str!("../README.md")]
3
// @@ begin lint list maintained by maint/add_warning @@
4
#![allow(renamed_and_removed_lints)] // @@REMOVE_WHEN(ci_arti_stable)
5
#![allow(unknown_lints)] // @@REMOVE_WHEN(ci_arti_nightly)
6
#![warn(missing_docs)]
7
#![warn(noop_method_call)]
8
#![warn(unreachable_pub)]
9
#![warn(clippy::all)]
10
#![deny(clippy::await_holding_lock)]
11
#![deny(clippy::cargo_common_metadata)]
12
#![deny(clippy::cast_lossless)]
13
#![deny(clippy::checked_conversions)]
14
#![warn(clippy::cognitive_complexity)]
15
#![deny(clippy::debug_assert_with_mut_call)]
16
#![deny(clippy::exhaustive_enums)]
17
#![deny(clippy::exhaustive_structs)]
18
#![deny(clippy::expl_impl_clone_on_copy)]
19
#![deny(clippy::fallible_impl_from)]
20
#![deny(clippy::implicit_clone)]
21
#![deny(clippy::large_stack_arrays)]
22
#![warn(clippy::manual_ok_or)]
23
#![deny(clippy::missing_docs_in_private_items)]
24
#![warn(clippy::needless_borrow)]
25
#![warn(clippy::needless_pass_by_value)]
26
#![warn(clippy::option_option)]
27
#![deny(clippy::print_stderr)]
28
#![deny(clippy::print_stdout)]
29
#![warn(clippy::rc_buffer)]
30
#![deny(clippy::ref_option_ref)]
31
#![warn(clippy::semicolon_if_nothing_returned)]
32
#![warn(clippy::trait_duplication_in_bounds)]
33
#![deny(clippy::unchecked_duration_subtraction)]
34
#![deny(clippy::unnecessary_wraps)]
35
#![warn(clippy::unseparated_literal_suffix)]
36
#![deny(clippy::unwrap_used)]
37
#![deny(clippy::mod_module_files)]
38
#![allow(clippy::let_unit_value)] // This can reasonably be done for explicitness
39
#![allow(clippy::uninlined_format_args)]
40
#![allow(clippy::significant_drop_in_scrutinee)] // arti/-/merge_requests/588/#note_2812945
41
#![allow(clippy::result_large_err)] // temporary workaround for arti#587
42
#![allow(clippy::needless_raw_string_hashes)] // complained-about code is fine, often best
43
#![allow(clippy::needless_lifetimes)] // See arti#1765
44
//! <!-- @@ end lint list maintained by maint/add_warning @@ -->
45

            
46
// TODO #1645 (either remove this, or decide to have it everywhere)
47
#![cfg_attr(not(all(feature = "full", feature = "experimental")), allow(unused))]
48

            
49
#[cfg(feature = "hs-service")]
50
pub(crate) mod build;
51
#[macro_use]
52
pub(crate) mod parse;
53
pub mod doc;
54
mod err;
55
pub mod types;
56
mod util;
57

            
58
// Use `#[doc(hidden)]` rather than pub(crate), because otherwise the doctest
59
// doesn't work.
60
#[doc(hidden)]
61
pub use util::batching_split_before;
62

            
63
pub use err::{BuildError, Error, NetdocErrorKind, Pos};
64

            
65
#[cfg(feature = "hs-service")]
66
#[cfg_attr(docsrs, doc(cfg(feature = "hs-service")))]
67
pub use build::NetdocBuilder;
68

            
69
/// Alias for the Result type returned by most objects in this module.
70
pub type Result<T> = std::result::Result<T, Error>;
71

            
72
/// Alias for the Result type returned by document-builder functions in this
73
/// module.
74
pub type BuildResult<T> = std::result::Result<T, BuildError>;
75

            
76
/// Indicates whether we should parse an annotated list of objects or a
77
/// non-annotated list.
78
#[derive(PartialEq, Debug, Eq)]
79
#[allow(clippy::exhaustive_enums)]
80
pub enum AllowAnnotations {
81
    /// Parsing a document where items might be annotated.
82
    ///
83
    /// Annotations are a list of zero or more items with keywords
84
    /// beginning with @ that precede the items that are actually part
85
    /// of the document.
86
    AnnotationsAllowed,
87
    /// Parsing a document where annotations are not allowed.
88
    AnnotationsNotAllowed,
89
}
90

            
91
/// Return a list of the protocols [supported](tor_protover::doc_supported)
92
/// by this crate.
93
237
pub fn supported_protocols() -> tor_protover::Protocols {
94
    use tor_protover::named::*;
95
    // WARNING: REMOVING ELEMENTS FROM THIS LIST CAN BE DANGEROUS!
96
    // SEE [`tor_protover::doc_changing`]
97
237
    [
98
237
        DESC_CROSSSIGN,
99
237
        DESC_NO_TAP,
100
237
        DESC_FAMILY_IDS,
101
237
        MICRODESC_ED25519_KEY,
102
237
        MICRODESC_NO_TAP,
103
237
        CONS_ED25519_MDS,
104
237
    ]
105
237
    .into_iter()
106
237
    .collect()
107
237
}
108

            
109
#[cfg(test)]
110
mod test {
111
    // @@ begin test lint list maintained by maint/add_warning @@
112
    #![allow(clippy::bool_assert_comparison)]
113
    #![allow(clippy::clone_on_copy)]
114
    #![allow(clippy::dbg_macro)]
115
    #![allow(clippy::mixed_attributes_style)]
116
    #![allow(clippy::print_stderr)]
117
    #![allow(clippy::print_stdout)]
118
    #![allow(clippy::single_char_pattern)]
119
    #![allow(clippy::unwrap_used)]
120
    #![allow(clippy::unchecked_duration_subtraction)]
121
    #![allow(clippy::useless_vec)]
122
    #![allow(clippy::needless_pass_by_value)]
123
    //! <!-- @@ end test lint list maintained by maint/add_warning @@ -->
124

            
125
    use super::*;
126

            
127
    #[test]
128
    fn protocols() {
129
        let pr = supported_protocols();
130
        let expected = "Cons=2 Desc=2-4 Microdesc=2-3".parse().unwrap();
131
        assert_eq!(pr, expected);
132
    }
133
}