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>Written as its text where the action is written as text (JSON), and as bytes elsewhere: never a list of numbers, one per byte.
Implementations§
Source§impl EncodedAction
impl EncodedAction
Sourcepub fn encode<A>(
type_id: impl Into<String>,
action: &A,
) -> Result<Self, ActionError>
pub fn encode<A>( type_id: impl Into<String>, action: &A, ) -> Result<Self, ActionError>
Serialize a concrete action under a registry type_id.
§Errors
Returns ActionError::Encode if action fails to serialize.
Sourcepub fn written(type_id: String, payload: Vec<u8>) -> Self
pub fn written(type_id: String, payload: Vec<u8>) -> Self
An action of type_id whose payload is payload, a group’s written
with what its members share once (crate::group_form).
Sourcepub fn encode_operation<T>(
type_id: impl Into<String>,
payload: &T,
) -> Result<Self, ActionError>where
T: Serialize,
pub fn encode_operation<T>(
type_id: impl Into<String>,
payload: &T,
) -> Result<Self, 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.
Source§impl EncodedAction
impl EncodedAction
Sourcepub fn content_parts(&self) -> Vec<String>
pub fn content_parts(&self) -> Vec<String>
The content this recorded action names, in payload order.
Sourcepub fn recorded_parts_of(&self, action: &Self) -> Option<ContentParts>
pub fn recorded_parts_of(&self, action: &Self) -> Option<ContentParts>
The parts this recorded action names, read from action, the action
as it ran: None when this is not action with its large parts kept
as content (another shape, or a part that is not what its reference
names).
Sourcepub fn resolve_content(
&self,
read: &dyn Fn(&str) -> Option<Vec<u8>>,
) -> Result<Result<Self, MissingContent>, ActionError>
pub fn resolve_content( &self, read: &dyn Fn(&str) -> Option<Vec<u8>>, ) -> Result<Result<Self, MissingContent>, ActionError>
The action as it ran, with every content reference replaced by the
content read returns for it, checked against its reference.
Trait Implementations§
Source§impl Clone for EncodedAction
impl Clone for EncodedAction
Source§impl Debug for EncodedAction
impl Debug for EncodedAction
Source§impl<'de> Deserialize<'de> for EncodedAction
impl<'de> Deserialize<'de> for EncodedAction
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>,
impl Eq for EncodedAction
Source§impl PartialEq for EncodedAction
impl PartialEq for EncodedAction
Source§impl Serialize for EncodedAction
impl Serialize for EncodedAction
impl StructuralPartialEq for EncodedAction
Auto Trait Implementations§
impl Forget for EncodedAction
impl Freeze for EncodedAction
impl Move 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§
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> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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