Struct EncodedAction
pub struct EncodedAction {
pub type_id: String,
pub payload: Vec<u8>,
}Expand description
A serialized action ready to cross a process/network boundary: the
registry type_id plus the JSON payload the matching decoder
reconstructs it from.
Fields§
§type_id: String§payload: Vec<u8>Implementations§
§impl EncodedAction
impl EncodedAction
pub fn encode<A>(
type_id: impl Into<String>,
action: &A,
) -> Result<EncodedAction, ActionError>
pub fn encode<A>( type_id: impl Into<String>, action: &A, ) -> Result<EncodedAction, ActionError>
Serialize a concrete action under a registry type_id.
§Errors
Returns ActionError::Encode if action fails to serialize.
pub fn written(type_id: String, payload: Vec<u8>) -> EncodedAction
pub fn written(type_id: String, payload: Vec<u8>) -> EncodedAction
An action of type_id whose payload is payload, a group’s written
with what its members share once (crate::group_form).
pub fn encode_operation<T>(
type_id: impl Into<String>,
payload: &T,
) -> Result<EncodedAction, ActionError>where
T: Serialize,
pub fn encode_operation<T>(
type_id: impl Into<String>,
payload: &T,
) -> Result<EncodedAction, ActionError>where
T: Serialize,
Serialize a non-document operation payload. Unlike Self::encode,
this intentionally requires no Action implementation: effects and
views are handled by the owning application, not replayed into a CRDT.
§Errors
Returns ActionError::Encode if payload fails to serialize.
§impl EncodedAction
impl EncodedAction
pub fn with_content_parts(
&self,
threshold: usize,
) -> Result<(EncodedAction, ContentParts), ActionError>
pub fn with_content_parts( &self, threshold: usize, ) -> Result<(EncodedAction, ContentParts), ActionError>
This action with every text or byte run of at least threshold
bytes kept as content: the recorded form, and the content to keep.
§Errors
A payload that is not JSON, or that already uses the reserved key.
pub fn content_parts(&self) -> Vec<String>
pub fn content_parts(&self) -> Vec<String>
The content this recorded action names, in payload order.
pub fn resolve_content(
&self,
read: &dyn Fn(&str) -> Option<Vec<u8>>,
) -> Result<Result<EncodedAction, MissingContent>, ActionError>
pub fn resolve_content( &self, read: &dyn Fn(&str) -> Option<Vec<u8>>, ) -> Result<Result<EncodedAction, MissingContent>, ActionError>
The action as it ran, with every content reference replaced by the
content read returns for it, checked against its hash.
§Errors
The first content that read does not have (or returns other bytes
for), or a payload that is not JSON.
Trait Implementations§
§impl Clone for EncodedAction
impl Clone for EncodedAction
§fn clone(&self) -> EncodedAction
fn clone(&self) -> EncodedAction
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for EncodedAction
impl Debug for EncodedAction
§impl<'de> Deserialize<'de> for EncodedAction
impl<'de> Deserialize<'de> for EncodedAction
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<EncodedAction, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<EncodedAction, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl PartialEq for EncodedAction
impl PartialEq for EncodedAction
§impl Serialize for EncodedAction
impl Serialize for EncodedAction
§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,
impl Eq for EncodedAction
impl StructuralPartialEq for EncodedAction
Auto Trait Implementations§
impl Freeze for EncodedAction
impl RefUnwindSafe for EncodedAction
impl Send for EncodedAction
impl Sync for EncodedAction
impl Unpin for EncodedAction
impl UnsafeUnpin for EncodedAction
impl UnwindSafe for EncodedAction
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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