Struct holo_hash::HoloHash[][src]

pub struct HoloHash<T: HashType> { /* fields omitted */ }

A HoloHash contains a vector of 36 bytes representing a 32-byte blake2b hash plus 4 bytes representing a DHT location. It also contains a zero-sized type which specifies what it is a hash of.

There is custom de/serialization implemented in [ser.rs]

Implementations

impl<T: HashType> HoloHash<T>[src]

pub fn from_raw_39(hash: Vec<u8>) -> HoloHashResult<Self>[src]

Raw constructor: Create a HoloHash from 39 bytes, using the prefix bytes to determine the hash_type

pub fn from_raw_39_panicky(hash: Vec<u8>) -> Self[src]

Raw constructor: Create a HoloHash from 39 bytes, using the prefix bytes to determine the hash_type. Panics if hash_type does not match.

pub fn from_raw_36_and_type(bytes: Vec<u8>, hash_type: T) -> Self[src]

Use a precomputed hash + location byte array in vec form, along with a type, to construct a hash. Used in this crate only, for testing.

pub fn retype<TT: HashType>(self, hash_type: TT) -> HoloHash<TT>[src]

Change the type of this HoloHash, keeping the same bytes

pub fn hash_type(&self) -> &T[src]

The HashType of this hash

pub fn get_raw_39(&self) -> &[u8][src]

Get the raw 39-byte Vec including the 3 byte prefix, base 32 bytes, and the 4 byte loc

pub fn get_raw_36(&self) -> &[u8][src]

Get 36-byte Vec which excludes the 3 byte prefix

pub fn get_raw_32(&self) -> &[u8][src]

Fetch just the core 32 bytes (without the 4 location bytes)

pub fn get_loc(&self) -> u32[src]

Fetch the holo dht location for this hash

pub fn into_inner(self) -> Vec<u8>[src]

consume into the inner byte vector

impl<T: HashType> HoloHash<T>[src]

pub fn from_raw_32_and_type(hash: Vec<u8>, hash_type: T) -> Self[src]

Construct a HoloHash from a 32-byte hash. The 3 prefix bytes will be added based on the provided HashType, and the 4 location bytes will be computed.

For convenience, 36 bytes can also be passed in, in which case the location bytes will used as provided, not computed.

impl<P: PrimitiveHashType> HoloHash<P>[src]

pub fn from_raw_36(hash: Vec<u8>) -> Self[src]

Construct from 36 raw bytes, using the known PrimitiveHashType

pub fn from_raw_32(hash: Vec<u8>) -> Self[src]

Construct a HoloHash from a prehashed raw 32-byte slice. The location bytes will be calculated.

Trait Implementations

impl<T: HashType> AsRef<[u8]> for HoloHash<T>[src]

impl<T: HashType> AsRef<HoloHash<T>> for HoloHashB64<T>[src]

impl<T: Clone + HashType> Clone for HoloHash<T>[src]

impl<T: HashType> Debug for HoloHash<T>[src]

impl<'de, T: HashType> Deserialize<'de> for HoloHash<T>[src]

impl<T: HashType> Display for HoloHash<T>[src]

impl<T: Eq + HashType> Eq for HoloHash<T>[src]

impl From<HoloHash<Agent>> for AnyDhtHash[src]

impl From<HoloHash<Agent>> for EntryHash[src]

impl From<HoloHash<AnyDht>> for HeaderHash[src]

impl From<HoloHash<AnyDht>> for EntryHash[src]

impl From<HoloHash<Entry>> for AnyDhtHash[src]

impl From<HoloHash<Entry>> for AgentPubKey[src]

impl From<HoloHash<Header>> for AnyDhtHash[src]

impl<T: HashType> From<HoloHash<T>> for HoloHashB64<T>[src]

impl<T: HashType> From<HoloHashB64<T>> for HoloHash<T>[src]

impl<T: HashType> HasHash<T> for HoloHash<T>[src]

impl<T: Hash + HashType> Hash for HoloHash<T>[src]

impl<T: HashType> IntoIterator for HoloHash<T>[src]

type Item = u8

The type of the elements being iterated over.

type IntoIter = IntoIter<Self::Item>

Which kind of iterator are we turning this into?

impl<T: Ord + HashType> Ord for HoloHash<T>[src]

impl<T: PartialEq + HashType> PartialEq<HoloHash<T>> for HoloHash<T>[src]

impl<T: PartialOrd + HashType> PartialOrd<HoloHash<T>> for HoloHash<T>[src]

impl<T: HashType> Serialize for HoloHash<T>[src]

impl<T: HashType> StructuralEq for HoloHash<T>[src]

impl<T: HashType> StructuralPartialEq for HoloHash<T>[src]

impl<P: PrimitiveHashType> TryFrom<&'_ String> for HoloHash<P>[src]

type Error = HoloHashError

The type returned in the event of a conversion error.

impl<P: PrimitiveHashType> TryFrom<&'_ str> for HoloHash<P>[src]

type Error = HoloHashError

The type returned in the event of a conversion error.

impl<T: HashType> TryFrom<SerializedBytes> for HoloHash<T>[src]

type Error = SerializedBytesError

The type returned in the event of a conversion error.

impl<P: PrimitiveHashType> TryFrom<String> for HoloHash<P>[src]

type Error = HoloHashError

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<T> RefUnwindSafe for HoloHash<T> where
    T: RefUnwindSafe

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

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

impl<T> Unpin for HoloHash<T> where
    T: Unpin

impl<T> UnwindSafe for HoloHash<T> where
    T: UnwindSafe

Blanket Implementations

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

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

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

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

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

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

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

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

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[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<V, T> VZip<V> for T where
    V: MultiLane<T>,