#[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>
impl<T> ServerReported<T>
Sourcepub fn value(&self) -> &T
pub fn value(&self) -> &T
Returns a reference to the server-reported value, which is not proof-verified.
Sourcepub fn into_value(self) -> T
pub fn into_value(self) -> T
Consumes the wrapper and returns the server-reported value, not proof-verified.
Sourcepub fn proof(&self) -> &[u8] ⓘ
pub fn proof(&self) -> &[u8] ⓘ
Returns the raw proof bytes the server sent, still unchecked. Empty when the response carried no proof.
Sourcepub fn try_map<U, E>(
self,
read: impl FnOnce(&T) -> Result<U, E>,
) -> Result<ServerReported<U>, E>
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,
impl<T> Clone for ServerReported<T>where
T: Clone,
Source§fn clone(&self) -> ServerReported<T>
fn clone(&self) -> ServerReported<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more