macro_rules! subprotocol_restricted_set {
{
$(#[$meta:meta])*
$v:vis struct $name:ident {
$(
$(#[$field_meta:meta])*
$field:ident
),* $(,)?
}
} => { ... };
}Expand description
Define a restricted set of subprotocol versions.
This supports a set of named subprotocols as defined in tor_protover::named.
This is useful when you want to restrict what subprotocol versions are allowed,
and also want to be able to exhaustively handle each subprotocol version.
If you don’t care about (or don’t want) the exhaustive property,
you might be better off defining a wrapper around Protocols instead.
Example:
tor_protover::subprotocol_restricted_set! {
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub(crate) struct SupportedSubprotocols {
RELAY_CRYPT_CGO,
RELAY_NTORV3,
}
}generates a struct of the form:
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub(crate) struct SupportedSubprotocols {
pub(crate) relay_crypt_cgo: bool,
pub(crate) relay_ntorv3: bool,
}