aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport/mod.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-31 13:27:22 +0100
committertv <tv@krebsco.de>2026-10-31 13:27:22 +0100
commit36ffffb89b1dfeca0163b6ecd9c46239aca6465e (patch)
tree2a7f4a5816b0efb517956ef208d7ec3ef1b4a5c3 /src/transport/mod.rs
parentf273b1a07e0ea78fb5b91d7916f596db899ab884 (diff)
sync messages are bytes outside the session
SyncPayload is now an opaque byte container in transport. SyncSession::generate returns the encoded payload, state::decode_sync(&payload) decodes it off the document lock (as before), and receive takes the decoded message, which is a type only the session can open. transport/mod.rs no longer imports Automerge.
Diffstat (limited to 'src/transport/mod.rs')
-rw-r--r--src/transport/mod.rs19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/transport/mod.rs b/src/transport/mod.rs
index c10e0d8..cef31ff 100644
--- a/src/transport/mod.rs
+++ b/src/transport/mod.rs
@@ -1,6 +1,5 @@
use anyhow::Result;
use async_trait::async_trait;
-use automerge::sync::Message;
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use std::boxed::Box;
@@ -681,23 +680,13 @@ impl DeltaSpec {
}
}
-/// An Automerge sync message in Automerge's own encoding. Decoded only where it is
-/// applied (`decode`), after the sender proved to be a member and off the consumer: a
-/// large message from anyone else costs nothing but its bytes.
+/// A sync message as the document's engine encodes it (`state::session`): bytes to the
+/// transports. Decoded only where it is applied (`state::decode_sync`), after the sender
+/// proved to be a member and off the consumer: a large message from anyone else costs
+/// nothing but its bytes.
#[derive(Clone)]
pub(crate) struct SyncPayload(pub(crate) bytes::Bytes);
-impl SyncPayload {
- pub(crate) fn encode(message: Message) -> Self {
- Self(message.encode().into())
- }
-
- pub(crate) fn decode(&self) -> Result<Message> {
- Message::decode(&self.0)
- .map_err(|error| anyhow::anyhow!("Automerge decode failed: {error:?}"))
- }
-}
-
/// Sizes instead of contents: logged messages stay short.
impl std::fmt::Debug for SyncPayload {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {