pub struct ProofSerializer {
pub stats: ProofSerializerStats,
}Expand description
Serializes and deserializes distributed proof trees.
The serializer is stateless apart from its ProofSerializerStats counter
set; it can therefore be shared freely across threads via an Arc.
Fields§
§stats: ProofSerializerStatsCumulative operation counters.
Implementations§
Source§impl ProofSerializer
impl ProofSerializer
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new ProofSerializer with zeroed counters.
Sourcepub fn serialize(
&self,
input: &ProofTreeInput,
) -> Result<SerializedProof, ProofSerError>
pub fn serialize( &self, input: &ProofTreeInput, ) -> Result<SerializedProof, ProofSerError>
Flattens input into a SerializedProof using DFS pre-order traversal.
§Errors
ProofSerError::EmptyTreewhennodesis empty.ProofSerError::MissingNodewhen the root or any child ID is absent.ProofSerError::CycleDetectedwhen the tree contains a cycle.
Sourcepub fn deserialize(
&self,
proof: &SerializedProof,
) -> Result<ProofTreeInput, ProofSerError>
pub fn deserialize( &self, proof: &SerializedProof, ) -> Result<ProofTreeInput, ProofSerError>
Reconstructs a ProofTreeInput from a SerializedProof.
§Errors
Returns ProofSerError::EmptyTree when the proof contains no nodes,
or ProofSerError::MissingNode when a referenced child is absent.
Sourcepub fn to_json(&self, proof: &SerializedProof) -> Result<String, ProofSerError>
pub fn to_json(&self, proof: &SerializedProof) -> Result<String, ProofSerError>
Encodes proof as a compact JSON string.
Sourcepub fn from_json(&self, json: &str) -> Result<SerializedProof, ProofSerError>
pub fn from_json(&self, json: &str) -> Result<SerializedProof, ProofSerError>
Decodes a SerializedProof from a JSON string.
Trait Implementations§
Source§impl Debug for ProofSerializer
impl Debug for ProofSerializer
Source§impl Default for ProofSerializer
impl Default for ProofSerializer
Source§fn default() -> ProofSerializer
fn default() -> ProofSerializer
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for ProofSerializer
impl RefUnwindSafe for ProofSerializer
impl Send for ProofSerializer
impl Sync for ProofSerializer
impl Unpin for ProofSerializer
impl UnsafeUnpin for ProofSerializer
impl UnwindSafe for ProofSerializer
Blanket Implementations§
impl<T> Allocation for T
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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