pub struct StateDelta<'a>(/* private fields */);
Expand description
Represents a modification to some state - similar to a diff in source code.
The exact format of a delta is determined by the contract. A contract implementation will determine whether a delta is valid - perhaps by verifying it is signed by someone authorized to modify the contract state. A delta may be created in response to a State Summary as part of the State Synchronization mechanism.
Implementations§
Source§impl StateDelta<'_>
impl StateDelta<'_>
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Extracts the owned data as a Vec<u8>
.
pub fn into_owned(self) -> StateDelta<'static>
Methods from Deref<Target = Cow<'a, [u8]>>§
Sourcepub fn is_borrowed(&self) -> bool
🔬This is a nightly-only experimental API. (cow_is_borrowed
)
pub fn is_borrowed(&self) -> bool
cow_is_borrowed
)Returns true if the data is borrowed, i.e. if to_mut
would require additional work.
§Examples
#![feature(cow_is_borrowed)]
use std::borrow::Cow;
let cow = Cow::Borrowed("moo");
assert!(cow.is_borrowed());
let bull: Cow<'_, str> = Cow::Owned("...moo?".to_string());
assert!(!bull.is_borrowed());
Sourcepub fn is_owned(&self) -> bool
🔬This is a nightly-only experimental API. (cow_is_borrowed
)
pub fn is_owned(&self) -> bool
cow_is_borrowed
)Returns true if the data is owned, i.e. if to_mut
would be a no-op.
§Examples
#![feature(cow_is_borrowed)]
use std::borrow::Cow;
let cow: Cow<'_, str> = Cow::Owned("moo".to_string());
assert!(cow.is_owned());
let bull = Cow::Borrowed("...moo?");
assert!(!bull.is_owned());
1.0.0 · Sourcepub fn to_mut(&mut self) -> &mut <B as ToOwned>::Owned
pub fn to_mut(&mut self) -> &mut <B as ToOwned>::Owned
Acquires a mutable reference to the owned form of the data.
Clones the data if it is not already owned.
§Examples
use std::borrow::Cow;
let mut cow = Cow::Borrowed("foo");
cow.to_mut().make_ascii_uppercase();
assert_eq!(
cow,
Cow::Owned(String::from("FOO")) as Cow<'_, str>
);
Trait Implementations§
Source§impl AsRef<[u8]> for StateDelta<'_>
impl AsRef<[u8]> for StateDelta<'_>
Source§impl<'a> Clone for StateDelta<'a>
impl<'a> Clone for StateDelta<'a>
Source§fn clone(&self) -> StateDelta<'a>
fn clone(&self) -> StateDelta<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'a> Debug for StateDelta<'a>
impl<'a> Debug for StateDelta<'a>
Source§impl<'a> Deref for StateDelta<'a>
impl<'a> Deref for StateDelta<'a>
Source§impl DerefMut for StateDelta<'_>
impl DerefMut for StateDelta<'_>
Source§impl<'de: 'a, 'a> Deserialize<'de> for StateDelta<'a>
impl<'de: 'a, 'a> Deserialize<'de> for StateDelta<'a>
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'a> From<&'a [u8]> for StateDelta<'a>
impl<'a> From<&'a [u8]> for StateDelta<'a>
Source§impl<'a> From<StateDelta<'a>> for UpdateData<'a>
impl<'a> From<StateDelta<'a>> for UpdateData<'a>
Source§fn from(delta: StateDelta<'a>) -> Self
fn from(delta: StateDelta<'a>) -> Self
Converts to this type from the input type.
Source§impl<'a> PartialEq for StateDelta<'a>
impl<'a> PartialEq for StateDelta<'a>
Source§impl<'a> Serialize for StateDelta<'a>
impl<'a> Serialize for StateDelta<'a>
impl<'a> Eq for StateDelta<'a>
impl<'a> StructuralPartialEq for StateDelta<'a>
Auto Trait Implementations§
impl<'a> Freeze for StateDelta<'a>
impl<'a> RefUnwindSafe for StateDelta<'a>
impl<'a> Send for StateDelta<'a>
impl<'a> Sync for StateDelta<'a>
impl<'a> Unpin for StateDelta<'a>
impl<'a> UnwindSafe for StateDelta<'a>
Blanket Implementations§
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
Mutably borrows from an owned value. Read more