Lines
77.78 %
Functions
50 %
Branches
100 %
//! Implementations of our useful traits, on external and parsing-mode types
use super::*;
impl ItemArgument for str {
fn write_arg_onto(&self, out: &mut ItemEncoder<'_>) -> Result<(), Bug> {
// Implements this
// https://gitlab.torproject.org/tpo/core/torspec/-/merge_requests/106
if self.is_empty() || self.chars().any(|c| !c.is_ascii_graphic()) {
return Err(internal!(
"invalid netdoc keyword line argument syntax {:?}",
self
));
}
out.args_raw_nonempty(&self);
Ok(())
impl ItemArgument for &str {
<str as ItemArgument>::write_arg_onto(self, out)
impl ItemArgument for Iso8601TimeSp {
// Unlike the macro'd formats, contains a space while still being one argument
let arg = self.to_string();
out.args_raw_nonempty(&arg.as_str());
impl ItemValueEncodable for Void {
fn write_item_value_onto(&self, _out: ItemEncoder) -> Result<(), Bug> {
void::unreachable(*self)
impl ItemObjectEncodable for Void {
fn label(&self) -> &str {
fn write_object_onto(&self, _: &mut Vec<u8>) -> Result<(), Bug> {
/// Types related to RSA keys
mod rsa {
use tor_llcrypto::pk::rsa::PublicKey;
impl ItemObjectEncodable for PublicKey {
"RSA PUBLIC KEY"
fn write_object_onto(&self, b: &mut Vec<u8>) -> Result<(), Bug> {
b.extend(self.to_der());
impl ItemValueEncodable for PublicKey {
fn write_item_value_onto(&self, out: ItemEncoder) -> Result<(), Bug> {
out.object(self);
/// HS POW
#[cfg(feature = "hs-pow-full")]
mod hs_pow {
use tor_hscrypto::pow::v1;
impl ItemArgument for v1::Seed {
let mut seed_bytes = vec![];
tor_bytes::Writer::write(&mut seed_bytes, &self)?;
out.add_arg(&Base64Unpadded::encode_string(&seed_bytes));
impl ItemArgument for v1::Effort {
out.add_arg(&<Self as Into<u32>>::into(*self));