Struct rings_core::dht::vnode::VirtualNode
source · pub struct VirtualNode {
pub did: Did,
pub data: Vec<Encoded>,
pub kind: VNodeType,
}Expand description
A VirtualNode is a piece of data with VNodeType and Did. You can save it to
PeerRing by ChordStorage protocol.
The Did of a Virtual Node is in the following format:
- If type value is VNodeType::Data, it’s sha1 of data topic.
- If type value is VNodeType::Subring, it’s sha1 of Subring name.
- If type value is VNodeType::RelayMessage, it’s the destination Did of message plus 1 (to ensure that the message is sent to the successor of destination), thus while destination node going online, it will sync message from its successor.
Fields§
§did: DidThe did of VirtualNode make it unique, and can be stored and retrieved on DHT.
data: Vec<Encoded>The data entity of VirtualNode, encoded by Encoder.
kind: VNodeTypeThe type indicates how the data is encoded and how the Did is generated.
Implementations§
source§impl VirtualNode
impl VirtualNode
sourcepub fn affine(&self, scalar: u16) -> Vec<VirtualNode>
pub fn affine(&self, scalar: u16) -> Vec<VirtualNode>
Affine Transport vnode to a list of affined did
sourcepub fn clone_with_did(&self, did: Did) -> Self
pub fn clone_with_did(&self, did: Did) -> Self
Clone and setup with new DID
sourcepub fn operate(&self, op: VNodeOperation) -> Result<Self>
pub fn operate(&self, op: VNodeOperation) -> Result<Self>
The entry point of VNodeOperation. Will dispatch to different operation handlers according to the variant.
sourcepub fn overwrite(&self, other: Self) -> Result<Self>
pub fn overwrite(&self, other: Self) -> Result<Self>
Overwrite current data with new data. The handler of VNodeOperation::Overwrite.
sourcepub fn extend(&self, other: Self) -> Result<Self>
pub fn extend(&self, other: Self) -> Result<Self>
This method is used to extend data to a Data type VirtualNode. The handler of VNodeOperation::Extend.
sourcepub fn touch(&self, other: Self) -> Result<Self>
pub fn touch(&self, other: Self) -> Result<Self>
This method is used to extend data to a Data type VirtualNode uniquely. If any element is already existed, move it to the end of the data vector. The handler of VNodeOperation::Touch.
sourcepub fn join_subring(&self, did: Did) -> Result<Self>
pub fn join_subring(&self, did: Did) -> Result<Self>
This method is used to join a subring. The handler of VNodeOperation::JoinSubring.
Trait Implementations§
source§impl Clone for VirtualNode
impl Clone for VirtualNode
source§fn clone(&self) -> VirtualNode
fn clone(&self) -> VirtualNode
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for VirtualNode
impl Debug for VirtualNode
source§impl<'de> Deserialize<'de> for VirtualNode
impl<'de> Deserialize<'de> for VirtualNode
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for VirtualNode
impl PartialEq for VirtualNode
source§fn eq(&self, other: &VirtualNode) -> bool
fn eq(&self, other: &VirtualNode) -> bool
self and other values to be equal, and is used
by ==.source§impl Serialize for VirtualNode
impl Serialize for VirtualNode
source§impl TryFrom<MessagePayload> for VirtualNode
impl TryFrom<MessagePayload> for VirtualNode
source§impl TryFrom<String> for VirtualNode
impl TryFrom<String> for VirtualNode
source§impl TryFrom<Subring> for VirtualNode
impl TryFrom<Subring> for VirtualNode
source§impl TryFrom<VirtualNode> for Subring
impl TryFrom<VirtualNode> for Subring
impl Eq for VirtualNode
impl StructuralPartialEq for VirtualNode
Auto Trait Implementations§
impl Freeze for VirtualNode
impl RefUnwindSafe for VirtualNode
impl Send for VirtualNode
impl Sync for VirtualNode
impl Unpin for VirtualNode
impl UnwindSafe for VirtualNode
Blanket Implementations§
source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more