[][src]Struct pow::Pow

pub struct Pow<T: Serialize> { /* fields omitted */ }

Proof of work over concrete type T. T can be any type that implements serde::Serialize.

Methods

impl<T: Serialize> Pow<T>[src]

pub fn prove_work(t: &T, difficulty: u128) -> Result<Pow<T>>[src]

Prove work over T.

Make sure difficulty is not too high. A 64 bit difficulty, for example, takes a long time on a general purpose processor.

Returns bincode::Error if serialization fails.

pub fn prove_work_serialized(prefix: &[u8], difficulty: u128) -> Pow<T>[src]

Prove work on an already serialized item of type T. The input is assumed to be serialized using network byte order.

Make sure difficulty is not too high. A 64 bit difficulty, for example, takes a long time on a general purpose processor.

pub fn score(&self, t: &T) -> Result<u128>[src]

Calculate the pow score of t and self.

pub fn score_serialized(&self, target: &[u8]) -> u128[src]

Calculate the pow score of an already serialized T and self. The input is assumed to be serialized using network byte order.

Trait Implementations

impl<T: Copy + Serialize> Copy for Pow<T>[src]

impl<T: PartialEq + Serialize> PartialEq<Pow<T>> for Pow<T>[src]

impl<T: Clone + Serialize> Clone for Pow<T>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T: Debug + Serialize> Debug for Pow<T>[src]

impl<T: Serialize> Serialize for Pow<T>[src]

impl<'de, T: Serialize> Deserialize<'de> for Pow<T>[src]

Auto Trait Implementations

impl<T> Send for Pow<T> where
    T: Send

impl<T> Sync for Pow<T> where
    T: Sync

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self