Struct rings_node::prelude::vnode::VirtualNode
source · 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, Global>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
source§impl VirtualNode
impl VirtualNode
sourcepub fn operate(&self, op: VNodeOperation) -> Result<VirtualNode, Error>
pub fn operate(&self, op: VNodeOperation) -> Result<VirtualNode, Error>
The entry point of VNodeOperation. Will dispatch to different operation handlers according to the variant.
sourcepub fn overwrite(&self, other: VirtualNode) -> Result<VirtualNode, Error>
pub fn overwrite(&self, other: VirtualNode) -> Result<VirtualNode, Error>
Overwrite current data with new data. The handler of VNodeOperation::Overwrite.
sourcepub fn extend(&self, other: VirtualNode) -> Result<VirtualNode, Error>
pub fn extend(&self, other: VirtualNode) -> Result<VirtualNode, Error>
This method is used to extend data to a Data type VirtualNode. The handler of VNodeOperation::Extend.
sourcepub fn touch(&self, other: VirtualNode) -> Result<VirtualNode, Error>
pub fn touch(&self, other: VirtualNode) -> Result<VirtualNode, Error>
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<VirtualNode, Error>
pub fn join_subring(&self, did: Did) -> Result<VirtualNode, Error>
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<VirtualNode, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<VirtualNode, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl PartialEq<VirtualNode> for VirtualNode
impl PartialEq<VirtualNode> 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§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
source§impl<T> TryFrom<MessagePayload<T>> for VirtualNodewhere
T: Serialize + DeserializeOwned,
impl<T> TryFrom<MessagePayload<T>> for VirtualNodewhere
T: Serialize + DeserializeOwned,
source§fn try_from(msg: MessagePayload<T>) -> Result<VirtualNode, Error>
fn try_from(msg: MessagePayload<T>) -> Result<VirtualNode, Error>
source§impl TryFrom<String> for VirtualNode
impl TryFrom<String> for VirtualNode
source§impl TryFrom<Subring> for VirtualNode
impl TryFrom<Subring> for VirtualNode
impl Eq for VirtualNode
impl StructuralEq for VirtualNode
impl StructuralPartialEq for VirtualNode
Auto Trait Implementations§
impl RefUnwindSafe for VirtualNode
impl Send for VirtualNode
impl Sync for VirtualNode
impl Unpin for VirtualNode
impl UnwindSafe for VirtualNode
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T> AsTaggedExplicit<'a> for Twhere
T: 'a,
impl<'a, T> AsTaggedExplicit<'a> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T> AsTaggedImplicit<'a> for Twhere
T: 'a,
impl<'a, T> AsTaggedImplicit<'a> for Twhere
T: 'a,
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.