Struct rings_node::prelude::vnode::VirtualNode
source · pub struct VirtualNode {
pub did: Did,
pub data: Vec<Encoded, Global>,
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: Did
The 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: VNodeType
The 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 affine(&self, scalar: u16) -> Vec<VirtualNode, Global>
pub fn affine(&self, scalar: u16) -> Vec<VirtualNode, Global>
Affine Transport vnode to a list of affined did
sourcepub fn clone_with_did(&self, did: Did) -> VirtualNode
pub fn clone_with_did(&self, did: Did) -> VirtualNode
Clone and setup with new DID
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<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata
§impl<'a, T> AsTaggedExplicit<'a> for Twhere
T: 'a,
impl<'a, T> AsTaggedExplicit<'a> for Twhere T: 'a,
§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> AsTaggedImplicit<'a> for Twhere
T: 'a,
impl<'a, T> AsTaggedImplicit<'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,
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
§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,
§fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>
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.