Use new owned ID types in more places

This commit is contained in:
Jonas Platte
2022-04-09 23:29:17 +02:00
parent efc869ce9d
commit 6100a0fa12
28 changed files with 133 additions and 130 deletions

View File

@@ -16,7 +16,7 @@ pub trait Event {
pub type StateMap<T> = BTreeMap<(EventType, Option<String>), T>;
/// A mapping of `EventId` to `T`, usually a `OriginalStateEvent`.
pub type EventMap<T> = BTreeMap<Box<EventId>, T>;
pub type EventMap<T> = BTreeMap<OwnedEventId, T>;
struct StateResolution {
// For now the StateResolution struct is empty. If "caching" `event_map`
@@ -30,10 +30,10 @@ impl StateResolution {
pub fn resolve<E: Event>(
room_id: &RoomId,
room_version: &RoomVersionId,
state_sets: &[StateMap<Box<EventId>>],
auth_events: Vec<Vec<Box<EventId>>>,
state_sets: &[StateMap<OwnedEventId>],
auth_events: Vec<Vec<OwnedEventId>>,
event_map: &mut EventMap<Arc<E>>,
) -> Result<StateMap<Box<EventId>>> {;
) -> Result<StateMap<OwnedEventId>> {;
}
```

View File

@@ -170,7 +170,7 @@ impl<E: Event> TestStore<E> {
}
/// Returns the events that correspond to the `event_ids` sorted in the same order.
fn get_events(&self, room_id: &RoomId, event_ids: &[Box<EventId>]) -> Result<Vec<Arc<E>>> {
fn get_events(&self, room_id: &RoomId, event_ids: &[OwnedEventId]) -> Result<Vec<Arc<E>>> {
let mut events = vec![];
for id in event_ids {
events.push(self.get_event(room_id, id)?);

View File

@@ -13,7 +13,7 @@ use ruma_common::{
RoomEventType, StateEventType,
},
serde::{Base64, Raw},
RoomVersionId, UserId,
OwnedUserId, RoomVersionId, UserId,
};
use serde::{de::IgnoredAny, Deserialize};
use serde_json::{from_str as from_json_str, value::RawValue as RawJsonValue};
@@ -30,7 +30,7 @@ struct GetMembership {
#[derive(Deserialize)]
struct RoomMemberContentFields {
membership: Option<Raw<MembershipState>>,
join_authorised_via_users_server: Option<Raw<Box<UserId>>>,
join_authorised_via_users_server: Option<Raw<OwnedUserId>>,
}
#[derive(Deserialize)]
@@ -65,7 +65,7 @@ pub fn auth_types_for_event(
struct RoomMemberContentFields {
membership: Option<Raw<MembershipState>>,
third_party_invite: Option<Raw<ThirdPartyInvite>>,
join_authorised_via_users_server: Option<Raw<Box<UserId>>>,
join_authorised_via_users_server: Option<Raw<OwnedUserId>>,
}
if let Some(state_key) = state_key {

View File

@@ -12,7 +12,7 @@ use ruma_common::{
room::member::{MembershipState, RoomMemberEventContent},
RoomEventType, StateEventType,
},
EventId, MilliSecondsSinceUnixEpoch, RoomVersionId, UserId,
EventId, MilliSecondsSinceUnixEpoch, OwnedUserId, RoomVersionId,
};
use serde::Deserialize;
use serde_json::from_str as from_json_str;
@@ -342,7 +342,7 @@ struct PowerLevelsContentFields {
serde(deserialize_with = "ruma_common::serde::btreemap_deserialize_v1_powerlevel_values")
)]
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
users: BTreeMap<Box<UserId>, Int>,
users: BTreeMap<OwnedUserId, Int>,
#[cfg_attr(
feature = "compat",