Add PduId wrapper struct

Death to Vec<u8>
This commit is contained in:
Lambda 2024-08-26 16:47:50 +00:00
parent 341f4213d0
commit 26322d5a95
15 changed files with 110 additions and 71 deletions

View file

@ -4,6 +4,7 @@ use crate::{
database::KeyValueDatabase,
service::{
self,
rooms::timeline::PduId,
sending::{Destination, RequestKey, SendingEventType},
},
services, utils, Error, Result,
@ -61,7 +62,7 @@ impl service::sending::Data for KeyValueDatabase {
for (destination, event) in requests {
let mut key = destination.get_prefix();
if let SendingEventType::Pdu(value) = &event {
key.extend_from_slice(value);
key.extend_from_slice(value.as_bytes());
} else {
key.extend_from_slice(
&services().globals.next_count()?.to_be_bytes(),
@ -202,7 +203,7 @@ fn parse_servercurrentevent(
Ok((
destination,
if value.is_empty() {
SendingEventType::Pdu(event.to_vec())
SendingEventType::Pdu(PduId::new(event.to_vec()))
} else {
SendingEventType::Edu(value)
},