Struct routing::StructuredData
[−]
[src]
pub struct StructuredData { // some fields omitted }
Mutable structured data.
These types may be stored unsigned with previous and current owner keys set to the same keys. Updates require a signature to validate.
Methods
impl StructuredData
[src]
fn new(type_tag: u64, name: XorName, version: u64, data: Vec<u8>, current_owner_keys: Vec<PublicKey>, previous_owner_keys: Vec<PublicKey>, signing_key: Option<&SecretKey>) -> Result<StructuredData, RoutingError>
Creates a new StructuredData
signed with signing_key
.
fn replace_with_other(&mut self, other: StructuredData) -> Result<(), RoutingError>
Replaces this data item with the given updated version if the update is valid, otherwise returns an error.
This allows types to be created and previous_owner_signatures
added one by one.
To transfer ownership, the current owner signs over the data; the previous owners field
must have the previous owners of version - 1
as the current owners of that last version.
fn name(&self) -> &XorName
Returns the name.
fn identifier(&self) -> DataIdentifier
Returns DataIdentifier
for this data element.
fn validate_self_against_successor(&self, other: &StructuredData) -> Result<(), RoutingError>
Verifies that other
is a valid update for self
; returns an error otherwise.
An update is valid if it doesn't change type tag or identifier (these are immutable), increases the version by 1 and is signed by (more than 50% of) the owners.
In case of an ownership transfer, the previous_owner_keys
in other
must match the
current_owner_keys
in self
.
fn add_signature(&mut self, secret_key: &SecretKey) -> Result<usize, RoutingError>
Adds a signature with the given secret_key
to the previous_owner_signatures
and returns
the number of signatures that are still required. If more than 50% of the previous owners
have signed, 0 is returned and validation is complete.
fn replace_signatures(&mut self, new_signatures: Vec<Signature>)
Overwrite any existing signatures with the new signatures provided.
fn get_type_tag(&self) -> u64
Get the type_tag
fn get_data(&self) -> &Vec<u8>
Get the serialised data
fn get_previous_owner_keys(&self) -> &Vec<PublicKey>
Get the previous owner keys
fn get_version(&self) -> u64
Get the version
fn get_owner_keys(&self) -> &Vec<PublicKey>
Get the current owner keys
fn get_previous_owner_signatures(&self) -> &Vec<Signature>
Get previous owner signatures
Trait Implementations
impl Hash for StructuredData
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.
impl Eq for StructuredData
[src]
impl PartialEq for StructuredData
[src]
fn eq(&self, __arg_0: &StructuredData) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &StructuredData) -> bool
This method tests for !=
.
impl PartialOrd for StructuredData
[src]
fn partial_cmp(&self, __arg_0: &StructuredData) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &StructuredData) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &StructuredData) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &StructuredData) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &StructuredData) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for StructuredData
[src]
fn cmp(&self, __arg_0: &StructuredData) -> Ordering
This method returns an Ordering
between self
and other
. Read more
impl Clone for StructuredData
[src]
fn clone(&self) -> StructuredData
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more