Struct holo_hash::HoloHash [−][src]
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]
fn deserialize<D>(deserializer: D) -> Result<HoloHash<T>, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl<T: HashType> Display for HoloHash<T>
[src]
impl<T: Eq + HashType> Eq for HoloHash<T>
[src]
impl From<HoloHash<Agent>> for AnyDhtHash
[src]
fn from(hash: AgentPubKey) -> Self
[src]
impl From<HoloHash<Agent>> for EntryHash
[src]
fn from(hash: AgentPubKey) -> EntryHash
[src]
impl From<HoloHash<AnyDht>> for HeaderHash
[src]
fn from(hash: AnyDhtHash) -> Self
[src]
impl From<HoloHash<AnyDht>> for EntryHash
[src]
fn from(hash: AnyDhtHash) -> Self
[src]
impl From<HoloHash<Entry>> for AnyDhtHash
[src]
impl From<HoloHash<Entry>> for AgentPubKey
[src]
fn from(hash: EntryHash) -> AgentPubKey
[src]
impl From<HoloHash<Header>> for AnyDhtHash
[src]
fn from(hash: HeaderHash) -> Self
[src]
impl<T: HashType> From<HoloHash<T>> for HoloHashB64<T>
[src]
fn from(original: HoloHash<T>) -> HoloHashB64<T>
[src]
impl<T: HashType> From<HoloHashB64<T>> for HoloHash<T>
[src]
fn from(original: HoloHashB64<T>) -> HoloHash<T>
[src]
impl<T: HashType> HasHash<T> for HoloHash<T>
[src]
impl<T: Hash + HashType> Hash for HoloHash<T>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
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?
fn into_iter(self) -> Self::IntoIter
[src]
impl<T: Ord + HashType> Ord for HoloHash<T>
[src]
fn cmp(&self, other: &HoloHash<T>) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<T: PartialEq + HashType> PartialEq<HoloHash<T>> for HoloHash<T>
[src]
impl<T: PartialOrd + HashType> PartialOrd<HoloHash<T>> for HoloHash<T>
[src]
fn partial_cmp(&self, other: &HoloHash<T>) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[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.
fn try_from(s: &String) -> Result<Self, HoloHashError>
[src]
impl<P: PrimitiveHashType> TryFrom<&'_ str> for HoloHash<P>
[src]
type Error = HoloHashError
The type returned in the event of a conversion error.
fn try_from(s: &str) -> Result<Self, HoloHashError>
[src]
impl<T: HashType> TryFrom<SerializedBytes> for HoloHash<T>
[src]
type Error = SerializedBytesError
The type returned in the event of a conversion error.
fn try_from(sb: SerializedBytes) -> Result<HoloHash<T>, SerializedBytesError>
[src]
impl<P: PrimitiveHashType> TryFrom<String> for HoloHash<P>
[src]
type Error = HoloHashError
The type returned in the event of a conversion error.
fn try_from(s: String) -> Result<Self, HoloHashError>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for HoloHash<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for HoloHash<T> where
T: Send,
T: Send,
impl<T> Sync for HoloHash<T> where
T: Sync,
T: Sync,
impl<T> Unpin for HoloHash<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for HoloHash<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,