13个版本 (破坏性更新)
0.11.0 | 2024年5月9日 |
---|---|
0.10.0 | 2023年10月5日 |
0.9.1 | 2023年2月15日 |
0.8.0 | 2022年9月12日 |
0.2.0 | 2021年6月21日 |
#1455 in Web编程
每月274次下载
在 12 个crate中使用(通过 ruma)
1.5MB
26K SLoC
Rust的Matrix状态解析!
/// Abstraction of a PDU so users can have their own PDU types.
pub trait Event {
/// The `EventId` of this event.
fn event_id(&self) -> &EventId;
/// The `RoomId` of this event.
fn room_id(&self) -> &RoomId;
/// The `UserId` of this event.
fn sender(&self) -> &UserId;
// and so on...
}
/// A mapping of event type and state_key to some value `T`, usually an `EventId`.
pub type StateMap<T> = BTreeMap<(StateEventType, Option<String>), T>;
/// A mapping of `EventId` to `T`, usually a `OriginalStateEvent`.
pub type EventMap<T> = BTreeMap<OwnedEventId, T>;
struct StateResolution {
// For now the StateResolution struct is empty. If "caching" `event_map`
// between `resolve` calls ends up being more efficient (probably not, as this would eat memory)
// it may have an `event_map` field. The `event_map` is all the events
// `StateResolution` has to know about to resolve state.
}
impl StateResolution {
/// The point of this all, resolve the possibly conflicting sets of events.
pub fn resolve<E: Event>(
room_id: &RoomId,
room_version: &RoomVersionId,
state_sets: &[StateMap<OwnedEventId>],
auth_events: Vec<Vec<OwnedEventId>>,
event_map: &mut EventMap<Arc<E>>,
) -> Result<StateMap<OwnedEventId>> {;
}
StateStore
trait 是对服务器(或甚至客户端)用于存储持久数据单元的数据库的抽象。
在反序列化任何PDU或其内容时,我们使用 ruma
的类型,这有助于避免许多类型检查逻辑,这些逻辑在 synapse 认证事件链时必须执行。
依赖关系
~8–20MB
~300K SLoC