tor_cell/relaycell/hs/pow/v1_stub.rs
1//! Stub; `v1` proof of work scheme has been disabled at compile time
2
3use tor_bytes::{EncodeResult, Reader, Result, Writer};
4use void::Void;
5
6/// Proof of work using the `v1` scheme, disabled at compile time
7///
8/// When disabled, the type can be named but it will never be constructed.
9/// The reader will generate an [`super::UnrecognizedProofOfWork`] instead.
10///
11#[derive(Debug, Clone, PartialEq)]
12pub struct ProofOfWorkV1(Void);
13
14impl ProofOfWorkV1 {
15 /// Stub reader implementation; never matches
16 #[allow(clippy::unnecessary_wraps)]
17 pub(super) fn try_take_body_from(_scheme: u8, _b: &mut Reader<'_>) -> Result<Option<Self>> {
18 Ok(None)
19 }
20
21 /// Stub writer implementation; uncallable due to void type
22 pub(super) fn write_onto<B: Writer + ?Sized>(&self, _b: &mut B) -> EncodeResult<()> {
23 void::unreachable(self.0)
24 }
25}