Skip to main content

ServerReported

Struct ServerReported 

Source
#[non_exhaustive]
pub struct ServerReported<T> { /* private fields */ }
Expand description

The read response types, defined in ton-net-lite and surfaced here. A value a liteserver returned without a checked proof.

A LiteClient checks nothing, so everything it returns is the server’s word and wears this wrapper to say so. A caller reaches the inner value through value or into_value and cannot mistake it for verified state.

The raw proof bytes the server sent are kept by proof, so the layer above can check them without another round trip. That is what ton-net-block does, and it is why the ton-net facade can hand back a proved value while the calls here still hand back this one.

Implementations§

Source§

impl<T> ServerReported<T>

Source

pub fn value(&self) -> &T

Returns a reference to the server-reported value, which is not proof-verified.

Source

pub fn into_value(self) -> T

Consumes the wrapper and returns the server-reported value, not proof-verified.

Source

pub fn proof(&self) -> &[u8] ⓘ

Returns the raw proof bytes the server sent, still unchecked. Empty when the response carried no proof.

Source

pub fn try_map<U, E>( self, read: impl FnOnce(&T) -> Result<U, E>, ) -> Result<ServerReported<U>, E>

Replaces the value with something read out of it, keeping the proof bytes.

Decoding a reported value leaves it just as unproven as it was, so the wrapper travels with it rather than being unwrapped and forgotten. The proof bytes stay attached for whatever checks them later.

§Errors

Returns whatever read returns, unchanged.

Trait Implementations§

Source§

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

Source§

fn clone(&self) -> ServerReported<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for ServerReported<T>
where T: Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for ServerReported<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for ServerReported<T>
where T: RefUnwindSafe,

§

impl<T> Send for ServerReported<T>
where T: Send,

§

impl<T> Sync for ServerReported<T>
where T: Sync,

§

impl<T> Unpin for ServerReported<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for ServerReported<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for ServerReported<T>
where T: UnwindSafe,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.