//! A row of this file, read back as the op it was — ONE of the three places a//! [`CottonOp`] is built (`mint` writes this file's own; `wire` reads a//! peer's bytes).//!//! Three kinds of row hold a write whole: a queued push in `_outbox`, a parked//! write in `_parked`, and the file's own//! tables, from which `changes` re-emits an author's rows for a peer. Each is//! read back HERE and nowhere else, so "what a stored op is" has one answer,//! and the op id is always the one the row kept: a retry or a re-send carries//! the same idempotency key, and the fold folds the second arrival to nothing.usecrate::actor::Actor;usecrate::driver::Row;usecrate::protocol::types::CottonOp;usecrate::rejected::RejectedOp;/// One `_outbox` row as the op that was queued: its id and its bytes.pubfn outbox_row(row: &Row) -> std::result::Result<CottonOp, String> {let bytes = match row.get("bytes") {Some(rusqlite::types::Value::Blob(bytes)) => bytes.as_slice(),Some(rusqlite::types::Value::Text(text)) => text.as_bytes(), _ => returnErr(format!("queued op {} holds no receipt bytes", row.text("op_id").unwrap_or_default())), };letmut op = crate::wire::from_bytes(row.text("op_id").unwrap_or_default().to_string(), bytes)?;// The signature the row kept travels with its bytes. A reader that did// not select `sig` gets an unsigned op, so every reader whose op TRAVELS// selects it (`tests/signed_receipts.rs` pins the three that do).ifletSome(rusqlite::types::Value::Blob(sig)) = row.get("sig") { op.sig = Some(crate::signed::sig_text(sig)); }Ok(op)}/// One `_writes` or `_tombstones` row as the op its receipt was.pubfn receipt_row(row: &Row) -> std::result::Result<CottonOp, String> { outbox_row(row)}/// One parked write as the op it was, or why it cannot be one: a row parked/// with no receipt bytes is a write nobody can fold again.pubfn rejected_row(row: &RejectedOp) -> std::result::Result<CottonOp, String> {letSome(bytes) = row.bytes.as_deref() else {returnErr("this write was parked with no receipt, so there is nothing to fold".to_string()); };letmut op = crate::wire::from_bytes(row.op_id.clone(), bytes)?; op.sig = row.sig.as_deref().map(crate::signed::sig_text);Ok(op)}/// An actor read back out of a column this file wrote — checked when it was/// minted, so a text that does not parse is a damaged row, named as such.pubfn actor(row: &Row, column: &str) -> std::result::Result<Actor, String> {letSome(text) = row.text(column) else {returnErr(format!("the `{column}` column holds no actor")); };Actor::from_wire(text)}