Struct bee_tangle::Tangle[][src]

pub struct Tangle<T, H = NullHooks<T>> where
    T: Clone
{ /* fields omitted */ }

A foundational, thread-safe graph datastructure to represent the IOTA Tangle.

Implementations

impl<T, H: Hooks<T>> Tangle<T, H> where
    T: Clone
[src]

pub fn new(hooks: H) -> Self[src]

Creates a new Tangle.

pub fn with_capacity(self, cap: usize) -> Self[src]

Create a new tangle with the given capacity.

pub fn resize(&self, len: usize)[src]

Change the maximum number of entries to store in the cache.

pub fn hooks(&self) -> &H[src]

Return a reference to the storage hooks used by this tangle.

pub async fn insert(
    &self,
    message_id: MessageId,
    message: Message,
    metadata: T
) -> Option<MessageRef>
[src]

Inserts a message, and returns a thread-safe reference to it in case it didn’t already exist.

pub async fn get_with<R>(
    &self,
    message_id: &MessageId,
    f: impl FnOnce(&mut Vertex<T>) -> Option<R>
) -> Option<R>
[src]

Get the data of a vertex associated with the given message_id.

pub async fn get(&self, message_id: &MessageId) -> Option<MessageRef>[src]

Get the data of a vertex associated with the given message_id.

pub async fn contains(&self, message_id: &MessageId) -> bool[src]

Returns whether the message is stored in the Tangle.

pub async fn get_metadata(&self, message_id: &MessageId) -> Option<T>[src]

Get the metadata of a vertex associated with the given message_id.

pub async fn get_metadata_maybe(&self, message_id: &MessageId) -> Option<T>[src]

Get the metadata of a vertex associated with the given message_id, if it’s in the cache.

pub async fn get_vertex(
    &self,
    message_id: &MessageId
) -> Option<impl Deref<Target = Vertex<T>> + '_>
[src]

Get the metadata of a vertex associated with the given message_id.

pub async fn set_metadata(&self, message_id: &MessageId, metadata: T)[src]

Updates the metadata of a particular vertex.

pub async fn update_metadata<R, Update>(
    &self,
    message_id: &MessageId,
    update: Update
) -> Option<R> where
    Update: FnOnce(&mut T) -> R, 
[src]

Updates the metadata of a vertex.

pub async fn len(&self) -> usize[src]

Returns the number of messages in the Tangle.

pub async fn is_empty(&self) -> bool[src]

Checks if the tangle is empty.

pub async fn get_children(
    &self,
    message_id: &MessageId
) -> Option<Vec<MessageId>>
[src]

Returns the children of a vertex, if we know about them.

pub async fn num_children(&self, message_id: &MessageId) -> usize[src]

Returns the number of children of a vertex.

Trait Implementations

impl<T, H: Hooks<T>> Default for Tangle<T, H> where
    T: Clone,
    H: Default
[src]

fn default() -> Self[src]

Returns the “default value” for a type. Read more

Auto Trait Implementations

impl<T, H = NullHooks<T>> !RefUnwindSafe for Tangle<T, H>

impl<T, H> Send for Tangle<T, H> where
    H: Send,
    T: Send

impl<T, H> Sync for Tangle<T, H> where
    H: Sync,
    T: Send + Sync

impl<T, H> Unpin for Tangle<T, H> where
    H: Unpin,
    T: Unpin

impl<T, H> UnwindSafe for Tangle<T, H> where
    H: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

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

Immutably borrows from an owned value. Read more

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

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

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V