Skip to main content

Entry

Struct Entry 

Source
pub struct Entry {
    pub now: i64,
    /* private fields */
}
Expand description

A stored entry preserving bit-perfect JSON bytes.

CRITICAL INVARIANT: The original JSON string is preserved exactly as received. This ensures correct czd computation, which hashes the exact bytes of pay.

§The Re-serialization Trap

A naive approach would parse JSON into serde_json::Value, then re-serialize for czd computation. This breaks signatures because re-serialization can change:

  • Field ordering
  • Whitespace
  • Number representation (e.g., 1.01)

By storing Box<RawValue>, we preserve the original bytes and extract pay from the same source, ensuring bit-perfect fidelity.

Fields§

§now: i64

The now timestamp extracted from pay.now (for filtering).

Implementations§

Source§

impl Entry

Source

pub fn from_json(json: String) -> Result<Self, EntryError>

Create an entry from a raw JSON string.

This is the primary constructor for entries loaded from storage. The original bytes are preserved exactly.

§Errors

Returns EntryError::InvalidJson if the string is not valid JSON. Returns EntryError::MissingNow if pay.now is missing or not an integer.

Source

pub fn from_raw_value(raw: Box<RawValue>) -> Result<Self, EntryError>

Create an entry from an owned RawValue.

Useful when deserializing from a format that already provides RawValue.

Source

pub fn from_value(value: &Value) -> Result<Self, EntryError>

Create an entry from a serde_json::Value.

Warning: This serializes the Value, which may not preserve original byte ordering. Use only when creating new entries (e.g., during export), not when loading from storage.

Source

pub fn raw_json(&self) -> &str

Get the raw JSON string.

This returns the exact bytes stored, suitable for I/O operations.

Source

pub fn as_value(&self) -> Result<Value, EntryError>

Parse the entry as a serde_json::Value.

Use this for field access (e.g., extracting typ, key). Do NOT use the resulting Value for czd computation - use pay_bytes() instead.

Source

pub fn pay_bytes(&self) -> Result<Vec<u8>, EntryError>

Extract the pay field as raw bytes, preserving exact byte sequence.

This is the critical method for czd computation. It extracts the pay field from the original JSON, preserving exact bytes including whitespace and field ordering.

§Implementation Note

We parse the raw JSON into a structure with RawValue for the pay field, then return those bytes. This ensures we’re extracting from the preserved original, not re-serializing.

Trait Implementations§

Source§

impl Clone for Entry

Source§

fn clone(&self) -> Entry

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Entry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Entry

§

impl RefUnwindSafe for Entry

§

impl Send for Entry

§

impl Sync for Entry

§

impl Unpin for Entry

§

impl UnsafeUnpin for Entry

§

impl UnwindSafe for Entry

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V