mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-13 20:26:52 +00:00
move core::pdu and core::state_res into core::matrix::
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
1 parent
4e5b87d0cd
commit
532dfd004d
91 files changed
+266
-205
No files matched your search
File renamed without changes.
@@ -0,0 +1,9 @@
|
||||
//! Core Matrix Library
|
||||
|
||||
pub mod event;
|
||||
pub mod pdu;
|
||||
pub mod state_res;
|
||||
|
||||
pub use event::Event;
|
||||
pub use pdu::{PduBuilder, PduCount, PduEvent, PduId, RawPduId, StateKey};
|
||||
pub use state_res::{EventTypeExt, RoomVersion, StateMap, TypeStateKey};
|
||||
@@ -1,7 +1,6 @@
|
||||
mod builder;
|
||||
mod content;
|
||||
mod count;
|
||||
mod event;
|
||||
mod event_id;
|
||||
mod filter;
|
||||
mod id;
|
||||
@@ -17,8 +16,8 @@ mod unsigned;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use ruma::{
|
||||
CanonicalJsonObject, CanonicalJsonValue, EventId, OwnedEventId, OwnedRoomId, OwnedServerName,
|
||||
OwnedUserId, UInt, events::TimelineEventType,
|
||||
CanonicalJsonObject, CanonicalJsonValue, EventId, MilliSecondsSinceUnixEpoch, OwnedEventId,
|
||||
OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, UInt, UserId, events::TimelineEventType,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::value::RawValue as RawJsonValue;
|
||||
@@ -27,12 +26,12 @@ pub use self::{
|
||||
Count as PduCount, Id as PduId, Pdu as PduEvent, RawId as RawPduId,
|
||||
builder::{Builder, Builder as PduBuilder},
|
||||
count::Count,
|
||||
event::Event,
|
||||
event_id::*,
|
||||
id::*,
|
||||
raw_id::*,
|
||||
state_key::{ShortStateKey, StateKey},
|
||||
};
|
||||
use super::Event;
|
||||
use crate::Result;
|
||||
|
||||
/// Persistent Data Unit (Event)
|
||||
@@ -79,6 +78,36 @@ impl Pdu {
|
||||
}
|
||||
}
|
||||
|
||||
impl Event for Pdu {
|
||||
type Id = OwnedEventId;
|
||||
|
||||
fn event_id(&self) -> &Self::Id { &self.event_id }
|
||||
|
||||
fn room_id(&self) -> &RoomId { &self.room_id }
|
||||
|
||||
fn sender(&self) -> &UserId { &self.sender }
|
||||
|
||||
fn event_type(&self) -> &TimelineEventType { &self.kind }
|
||||
|
||||
fn content(&self) -> &RawJsonValue { &self.content }
|
||||
|
||||
fn origin_server_ts(&self) -> MilliSecondsSinceUnixEpoch {
|
||||
MilliSecondsSinceUnixEpoch(self.origin_server_ts)
|
||||
}
|
||||
|
||||
fn state_key(&self) -> Option<&str> { self.state_key.as_deref() }
|
||||
|
||||
fn prev_events(&self) -> impl DoubleEndedIterator<Item = &Self::Id> + Send + '_ {
|
||||
self.prev_events.iter()
|
||||
}
|
||||
|
||||
fn auth_events(&self) -> impl DoubleEndedIterator<Item = &Self::Id> + Send + '_ {
|
||||
self.auth_events.iter()
|
||||
}
|
||||
|
||||
fn redacts(&self) -> Option<&Self::Id> { self.redacts.as_ref() }
|
||||
}
|
||||
|
||||
/// Prevent derived equality which wouldn't limit itself to event_id
|
||||
impl Eq for Pdu {}
|
||||
|
||||
@@ -87,12 +116,12 @@ impl PartialEq for Pdu {
|
||||
fn eq(&self, other: &Self) -> bool { self.event_id == other.event_id }
|
||||
}
|
||||
|
||||
/// Ordering determined by the Pdu's ID, not the memory representations.
|
||||
impl PartialOrd for Pdu {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { Some(self.cmp(other)) }
|
||||
}
|
||||
|
||||
/// Ordering determined by the Pdu's ID, not the memory representations.
|
||||
impl Ord for Pdu {
|
||||
fn cmp(&self, other: &Self) -> Ordering { self.event_id.cmp(&other.event_id) }
|
||||
}
|
||||
|
||||
/// Ordering determined by the Pdu's ID, not the memory representations.
|
||||
impl PartialOrd for Pdu {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { Some(self.cmp(other)) }
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -4,7 +4,6 @@ pub(crate) mod error;
|
||||
pub mod event_auth;
|
||||
mod power_levels;
|
||||
mod room_version;
|
||||
mod state_event;
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_utils;
|
||||
@@ -36,9 +35,12 @@ use self::power_levels::PowerLevelsContentFields;
|
||||
pub use self::{
|
||||
event_auth::{auth_check, auth_types_for_event},
|
||||
room_version::RoomVersion,
|
||||
state_event::Event,
|
||||
};
|
||||
use crate::{debug, pdu::StateKey, trace, warn};
|
||||
use crate::{
|
||||
debug,
|
||||
matrix::{event::Event, pdu::StateKey},
|
||||
trace, warn,
|
||||
};
|
||||
|
||||
/// A mapping of event type and state_key to some value `T`, usually an
|
||||
/// `EventId`.
|
||||
File renamed without changes.
@@ -11,9 +11,9 @@ use ruma::{
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use serde_json::{Error, from_str as from_json_str};
|
||||
use tracing::error;
|
||||
|
||||
use super::{Result, RoomVersion};
|
||||
use crate::error;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct IntRoomPowerLevelsEventContent {
|
||||
File renamed without changes.
@@ -28,7 +28,10 @@ use serde_json::{
|
||||
|
||||
pub(crate) use self::event::PduEvent;
|
||||
use super::auth_types_for_event;
|
||||
use crate::{Event, EventTypeExt, Result, StateMap, info};
|
||||
use crate::{
|
||||
Result, info,
|
||||
matrix::{Event, EventTypeExt, StateMap},
|
||||
};
|
||||
|
||||
static SERVER_TIMESTAMP: AtomicU64 = AtomicU64::new(0);
|
||||
|
||||
+2
-4
@@ -6,11 +6,10 @@ pub mod debug;
|
||||
pub mod error;
|
||||
pub mod info;
|
||||
pub mod log;
|
||||
pub mod matrix;
|
||||
pub mod metrics;
|
||||
pub mod mods;
|
||||
pub mod pdu;
|
||||
pub mod server;
|
||||
pub mod state_res;
|
||||
pub mod utils;
|
||||
|
||||
pub use ::arrayvec;
|
||||
@@ -23,9 +22,8 @@ pub use ::tracing;
|
||||
pub use config::Config;
|
||||
pub use error::Error;
|
||||
pub use info::{rustc_flags_capture, version, version::version};
|
||||
pub use pdu::{Event, PduBuilder, PduCount, PduEvent, PduId, RawPduId, StateKey};
|
||||
pub use matrix::{Event, EventTypeExt, PduCount, PduEvent, PduId, RoomVersion, pdu, state_res};
|
||||
pub use server::Server;
|
||||
pub use state_res::{EventTypeExt, RoomVersion, StateMap, TypeStateKey};
|
||||
pub use utils::{ctor, dtor, implement, result, result::Result};
|
||||
|
||||
pub use crate as conduwuit_core;
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
use ruma::{MilliSecondsSinceUnixEpoch, OwnedEventId, RoomId, UserId, events::TimelineEventType};
|
||||
use serde_json::value::RawValue as RawJsonValue;
|
||||
|
||||
use super::Pdu;
|
||||
pub use crate::state_res::Event;
|
||||
|
||||
impl Event for Pdu {
|
||||
type Id = OwnedEventId;
|
||||
|
||||
fn event_id(&self) -> &Self::Id { &self.event_id }
|
||||
|
||||
fn room_id(&self) -> &RoomId { &self.room_id }
|
||||
|
||||
fn sender(&self) -> &UserId { &self.sender }
|
||||
|
||||
fn event_type(&self) -> &TimelineEventType { &self.kind }
|
||||
|
||||
fn content(&self) -> &RawJsonValue { &self.content }
|
||||
|
||||
fn origin_server_ts(&self) -> MilliSecondsSinceUnixEpoch {
|
||||
MilliSecondsSinceUnixEpoch(self.origin_server_ts)
|
||||
}
|
||||
|
||||
fn state_key(&self) -> Option<&str> { self.state_key.as_deref() }
|
||||
|
||||
fn prev_events(&self) -> impl DoubleEndedIterator<Item = &Self::Id> + Send + '_ {
|
||||
self.prev_events.iter()
|
||||
}
|
||||
|
||||
fn auth_events(&self) -> impl DoubleEndedIterator<Item = &Self::Id> + Send + '_ {
|
||||
self.auth_events.iter()
|
||||
}
|
||||
|
||||
fn redacts(&self) -> Option<&Self::Id> { self.redacts.as_ref() }
|
||||
}
|
||||
Reference in new issue
Block a user