hscrypto: Make several types Readable+Writeable
Specifically, RendCookie, Subcredential, HsId, and HsBlindId.
This commit is contained in:
parent
886faa96b3
commit
d69ed3bc62
|
@ -3982,6 +3982,7 @@ dependencies = [
|
||||||
"signature 1.6.4",
|
"signature 1.6.4",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tor-basic-utils",
|
"tor-basic-utils",
|
||||||
|
"tor-bytes",
|
||||||
"tor-llcrypto",
|
"tor-llcrypto",
|
||||||
"tor-units",
|
"tor-units",
|
||||||
]
|
]
|
||||||
|
|
|
@ -22,6 +22,7 @@ rand_core = "0.6.2"
|
||||||
serde = { version = "1.0.103", features = ["derive"] }
|
serde = { version = "1.0.103", features = ["derive"] }
|
||||||
signature = "1"
|
signature = "1"
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
|
tor-bytes = { version = "0.6.1", path = "../tor-bytes" }
|
||||||
tor-llcrypto = { version = "0.4.2", path = "../tor-llcrypto", features = [
|
tor-llcrypto = { version = "0.4.2", path = "../tor-llcrypto", features = [
|
||||||
"hsv3-client",
|
"hsv3-client",
|
||||||
"hsv3-service",
|
"hsv3-service",
|
||||||
|
|
|
@ -59,6 +59,17 @@ macro_rules! define_bytes {
|
||||||
inp.0.into()
|
inp.0.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl tor_bytes::Readable for $name {
|
||||||
|
fn take_from(r: &mut tor_bytes::Reader<'_>) -> tor_bytes::Result<Self> {
|
||||||
|
Ok(Self::new(r.extract()?))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl tor_bytes::Writeable for $name {
|
||||||
|
fn write_onto<B:tor_bytes::Writer+?Sized>(&self, w: &mut B) -> tor_bytes::EncodeResult<()> {
|
||||||
|
w.write_all(&self.0.as_ref()[..]);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue