Jason Volk
d96d981475
Make to_cow_str() for event types public as at least some hedge against unconditional to_string().
...
Signed-off-by: Jason Volk <jason@zemos.net>
2024-10-25 02:44:06 +00:00
Benjamin Bouvier
fec2152d87
events: allow deserializing an event content with a type ( #1850 )
...
This allows deserializing all the `*EventContent` types into a parent `Any{...}EventContent`, assuming we know the type of the underlying event.
Required for serializing/deserializing the content of events we'd like to send, across application restarts, as in https://github.com/matrix-org/matrix-rust-sdk/issues/3361 for the Rust SDK.
---
* events: add deserialize_with_type to all the *EventContent types
* events: add smoke test for deserializing an event content with a type
* events: add a test for deserializing a secret storage key event content
* events: add fix for correctly matching events with a type fragment
* Address review comments.
2024-06-24 10:55:12 +02:00
Kévin Commaille
00a17dbe9d
events: Fix deserialization of AnyGlobalAccountDataEvent for variants with type fragment
2024-06-21 18:10:31 +02:00
Kévin Commaille
a70f99a233
macros: Allow EventContent derive macro to work on enums
...
Requires to disable all automatic type generation.
2023-09-15 13:19:22 +02:00
Jonas Platte
31331f3165
Bring back ruma-events
...
Co-authored-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-08-28 10:23:54 +02:00
Jonas Platte
ba2914a22a
macros: Simplify symbol path
2023-08-25 10:36:25 +02:00
Jonas Platte
8e10064364
Enforce import grouping
...
Includes a few manual changes to make rustfmt behave a bit better.
2023-08-22 12:31:49 +02:00
Kévin Commaille
bcae4e5799
chore: Use .is_some_and(…) instead of .map_or(false, …)
2023-08-14 16:17:25 +02:00
Kévin Commaille
e780633cce
events: Allow to declare events without a stable prefix
2023-07-27 16:04:58 +02:00
Jonas Platte
3dac70ead9
Remove most unreachable visibility modifiers
2023-07-19 14:32:14 +02:00
Jonas Platte
ad457c1c11
Rerun rustfmt
2023-07-19 13:53:15 +02:00
Jonas Platte
cfc4c66820
Rewrap lines to fit macro input in maximum line length
2023-07-19 13:53:03 +02:00
Jonas Platte
cb512f01d6
macros: Fix weird indentation
2023-04-24 17:02:23 +02:00
Jonas Platte
53622f8ce0
macros: Upgrade syn to 2.0
2023-04-24 17:02:23 +02:00
Jonas Platte
89e398fd06
events: Add back relations accessors for message-like event enums
2023-04-18 11:33:54 +02:00
Jonas Platte
19d44489c3
events: Split bundled relations into two types
...
One for message-like events, one for state events.
2023-03-15 14:49:49 +01:00
Jonas Platte
0599eb1226
macros: Fix confusing name of local bindings
2023-03-15 12:33:09 +01:00
Jonas Platte
9c65a7dcae
events: Use input visibility for generated types in EventContent derive
2023-02-07 20:55:53 +01:00
Jonas Platte
19006cd047
Clean up code blocks in doc strings
2023-02-01 16:58:47 +01:00
Jonas Platte
62ed200a56
events: Use possibly-redacted content for StrippedStateEvent
2023-01-16 21:28:53 +01:00
Jonas Platte
2eba14f0cc
events: Rework the content traits
2023-01-16 21:28:53 +01:00
Jonas Platte
49a0650f62
events: Remove EventKind
...
The EventType associated type on EventContent practically provides the
same information.
2023-01-16 21:17:00 +01:00
Jonas Platte
7de5893b83
common: Use quoted string as Debug representation of event types
2023-01-13 12:54:28 +01:00
Jonas Platte
3a722965f5
macros: Refactor event content generation
2023-01-10 11:46:49 +01:00
Jonas Platte
68a596dbc3
events: Remove RedactedEventContent trait
2023-01-10 11:46:49 +01:00
Kévin Commaille
1d8ea75f6f
events: Remove EventContent::from_parts
2023-01-10 11:37:31 +01:00
Kévin Commaille
dc591647f8
events: Remove StateUnsignedFromParts
...
Replace it with a bound on DeserializeOwned
2023-01-10 11:37:31 +01:00
Kévin Commaille
97b212795a
events: Create EventContentFromType
...
Implement it for:
- event contents that implement Deserialize
- event contents with event types with a suffix
- custom event contents
2023-01-10 11:37:31 +01:00
Kévin Commaille
ca78825e94
events: rename RoomEventType to TimelineEventType
2023-01-03 10:36:13 +01:00
Kévin Commaille
cd74cdcc0e
events: Generate PossiblyRedacted type for original state events
...
Fix deserialization of redacted prev_content
Can be overriden with the `custom_possibly_redacted` attribute
Co-authored-by: Jonas Platte <jplatte@element.io>
2023-01-03 10:28:40 +01:00
Kévin Commaille
9d8c9c477f
events: Move Unsigned type to new OriginalStateEventContent trait
...
Only original events require it.
2022-12-23 17:55:03 +01:00
Kévin Commaille
e4678284ca
events: Add accessor for AnyFullStateEventContent's event type
2022-12-20 10:46:34 +01:00
Kévin Commaille
baaf73adbc
events: Add accessors for state events' original or redacted content
2022-12-19 13:13:12 +00:00
Jonas Platte
190205cfb1
events: Remove Option around BundledRelations
...
… because the type has its own empty state (all fields being None).
2022-12-15 16:46:12 +01:00
Jonas Platte
ad3c27d927
events: Make redacted_because non-optional in RedactedUnsigned
2022-12-15 12:47:27 +01:00
Jonas Platte
cdabe8e52d
events: Remove Serialize impls for all event types except ToDeviceEvent
2022-12-15 10:41:30 +01:00
Jonas Platte
675e6f43cd
events: Remove the Redact trait
...
It has not proven to be useful, being used by no downstream project.
2022-12-14 12:49:15 +01:00
Jonas Platte
a5c5b0b137
Make clippy happy
2022-12-09 11:45:04 +01:00
Kévin Commaille
61a9d65b71
events: Rename events::relation::Relations to BundledRelations
2022-11-25 22:33:37 +01:00
Kévin Commaille
dab2956039
events: Use a struct for parsing of EventContent attributes
2022-11-12 11:14:04 +01:00
Jonas Platte
94990f60f2
events: Don't skip serializing empty content of redacted events
2022-11-09 17:11:50 +01:00
Jonas Platte
c7e84c5249
Fix clippy lints
...
Automated using `cargo clippy --fix`.
2022-10-26 13:38:29 +02:00
Kévin Commaille
ec853e968a
events: Generate structs without relation for events that can be replaced
2022-10-17 20:27:49 +02:00
Jonas Platte
028eb8a457
events: Remove deprecated API
2022-09-22 11:50:22 +02:00
Jonas Platte
97387f36c1
macros: Fix outdated documentation
2022-09-22 11:47:32 +02:00
Jonas Platte
fa61cc1248
events: Add relations accessors to event enums
2022-09-16 11:34:54 +02:00
Jonas Platte
956871cfa6
macros: Rename is_room to is_timeline
2022-09-16 11:28:16 +02:00
Jonas Platte
aa8e48d1c3
events: Allow customizing the unsigned type of state events
2022-09-12 13:10:10 +02:00
Jonas Platte
35d8bdd5a1
events: Move StateUnsigned::_from_parts into a trait
2022-09-12 12:03:29 +02:00
Jonas Platte
674137c41d
events: Use CanBeEmpty trait for skipping unsigned serialization
2022-09-12 11:44:05 +02:00