pub struct StreamVerifier { /* private fields */ }Expand description
HMAC chain verifier for StreamBlock.
Implementations§
Source§impl StreamVerifier
impl StreamVerifier
Sourcepub fn new(key: [u8; 32], topic: String) -> Self
pub fn new(key: [u8; 32], topic: String) -> Self
Create a new verifier with no policy enforcement (MAC chain only) — legacy behaviour.
AEAD opening is OFF (enc_key = None); use StreamVerifier::with_enc_key to
open transport-sealed Tagged payloads (#321).
Sourcepub fn with_enc_key(self, enc_key: [u8; 32]) -> Self
pub fn with_enc_key(self, enc_key: [u8; 32]) -> Self
Set the transport AEAD key so sealed Tagged payloads are opened (#321).
Builder-style; pass the enc_key from derive_client_stream_keys. With it
set, the verifier decrypts each Tagged block back into Data/Complete/Error and
fails closed on tamper / wrong key.
Sourcepub fn with_epoch_ratchet(self, ratchet: StreamEpochRatchet) -> Self
pub fn with_epoch_ratchet(self, ratchet: StreamEpochRatchet) -> Self
Install the identified epoch profile at its current committed epoch.
Sourcepub fn accept_epoch_commit(&mut self, commit: &StreamEpochCommit) -> Result<()>
pub fn accept_epoch_commit(&mut self, commit: &StreamEpochCommit) -> Result<()>
Authenticate and atomically install the next epoch. Failed, replayed, skipped, or cross-stream commits leave the current verifier state intact.
Sourcepub fn with_policy(
key: [u8; 32],
topic: String,
policy: VerifierContract,
) -> Self
pub fn with_policy( key: [u8; 32], topic: String, policy: VerifierContract, ) -> Self
Create a verifier that enforces policy (#163) — used by codegen-generated consumers,
where the contract is a compile-time constant from the service’s API contract.
Sourcepub fn requires_terminal(&self) -> bool
pub fn requires_terminal(&self) -> bool
True if this stream’s policy requires a terminal payload before EOF; the consumer must
reject an EOF when this is true and StreamVerifier::terminal_seen is false.
Sourcepub fn terminal_seen(&self) -> bool
pub fn terminal_seen(&self) -> bool
True once a terminal (Complete/Error) payload has been observed.
Sourcepub fn verify(&mut self, frames: &[Vec<u8>]) -> Result<Vec<StreamPayload>>
pub fn verify(&mut self, frames: &[Vec<u8>]) -> Result<Vec<StreamPayload>>
Verify frames and return parsed payloads.
Expected frames: [topic, capnp StreamBlock, 16-byte MAC]
Sourcepub fn verify_parts(
&mut self,
received_topic: &[u8],
capnp_data: &[u8],
received_mac: &[u8],
) -> Result<Vec<StreamPayload>>
pub fn verify_parts( &mut self, received_topic: &[u8], capnp_data: &[u8], received_mac: &[u8], ) -> Result<Vec<StreamPayload>>
Zero-copy variant of verify over borrowed slices.
verify is a thin wrapper over this. The moq path calls it directly with
slices into the received Bytes frame (verify_moq_frame), so a large
payload (e.g. a pipeline activation tensor) is never copied into owned
per-frame Vecs — combined with the multi-part MAC and
read_message_from_flat_slice below, the block stays a view into the
receive buffer end-to-end.
Auto Trait Implementations§
impl Freeze for StreamVerifier
impl RefUnwindSafe for StreamVerifier
impl Send for StreamVerifier
impl Sync for StreamVerifier
impl Unpin for StreamVerifier
impl UnsafeUnpin for StreamVerifier
impl UnwindSafe for StreamVerifier
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more