From 744928b2062ace4f3581d8d60917b72689dd4988 Mon Sep 17 00:00:00 2001 From: timedout Date: Mon, 21 Sep 2026 03:07:04 +0100 Subject: [PATCH] style: Update docstring for `Pdu.set_unsigned` --- src/core/matrix/pdu/unsigned.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/core/matrix/pdu/unsigned.rs b/src/core/matrix/pdu/unsigned.rs index 6bdc0f79e..9c3197245 100644 --- a/src/core/matrix/pdu/unsigned.rs +++ b/src/core/matrix/pdu/unsigned.rs @@ -13,11 +13,21 @@ use crate::Event; type Unsigned = BTreeMap>; impl Pdu { - /// Set the `unsigned` field of the PDU using only information in the PDU. - /// Some unsigned data is already set within the database (eg. prev events, - /// threads). Once this is done, other data must be calculated from the - /// database (eg. relations) This is for server-to-client events. - /// Backfill handles this itself. + /// Sets the `unsigned` field of the PDU using a mix of the provided + /// optional data, and information available in the PDU itself. The + /// `unsigned` field will always be inserted if it is not attached to the + /// PDU, however no operations will be performed if `unsigned` is present + /// but malformed and unparseable. + /// + /// `age` is always inserted and is calculated based on the time of the + /// function call. `membership`, `prev_content`, and `redacted_by` are + /// inserted if not `None`. If `user_id` is `None`, `transaction_id` will be + /// removed. The sticky event TTL field is always inserted and calculated + /// (per `age`) if the PDU is sticky. + /// + /// This function panics if any value cannot be serialised, which should not + /// happen provided `membership`, `prev_content`, and `redacted_because` are + /// well-formed. pub fn set_unsigned( &mut self, user_id: Option<&ruma::UserId>,