workaround some large type name length issues

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2025-03-30 22:59:29 +00:00
parent db99d3a001
commit d60920c728
14 changed files with 41 additions and 32 deletions

View file

@ -1,3 +1,4 @@
#![type_length_limit = "16384"] //TODO: reduce me
#![allow(clippy::toplevel_ref_arg)]
pub mod client;

View file

@ -136,6 +136,7 @@ macro_rules! err_log {
}
#[macro_export]
#[collapse_debuginfo(yes)]
macro_rules! err_lev {
(debug_warn) => {
if $crate::debug::logging() {

View file

@ -1,3 +1,5 @@
#![type_length_limit = "12288"]
pub mod alloc;
pub mod config;
pub mod debug;

View file

@ -149,7 +149,6 @@ where
&event_fetch,
parallel_fetches,
)
.boxed()
.await?;
debug!(count = sorted_control_levels.len(), "power events");
@ -164,7 +163,6 @@ where
&event_fetch,
parallel_fetches,
)
.boxed()
.await?;
debug!(count = resolved_control.len(), "resolved power events");
@ -192,7 +190,6 @@ where
let sorted_left_events =
mainline_sort(&events_to_resolve, power_event.cloned(), &event_fetch, parallel_fetches)
.boxed()
.await?;
trace!(list = ?sorted_left_events, "events left, sorted");
@ -204,7 +201,6 @@ where
&event_fetch,
parallel_fetches,
)
.boxed()
.await?;
// Add unconflicted state to the resolved state

View file

@ -173,6 +173,7 @@ macro_rules! is_equal {
/// Functor for |x| *x.$i
#[macro_export]
#[collapse_debuginfo(yes)]
macro_rules! deref_at {
($idx:tt) => {
|t| *t.$idx
@ -181,6 +182,7 @@ macro_rules! deref_at {
/// Functor for |ref x| x.$i
#[macro_export]
#[collapse_debuginfo(yes)]
macro_rules! ref_at {
($idx:tt) => {
|ref t| &t.$idx
@ -189,6 +191,7 @@ macro_rules! ref_at {
/// Functor for |&x| x.$i
#[macro_export]
#[collapse_debuginfo(yes)]
macro_rules! val_at {
($idx:tt) => {
|&t| t.$idx
@ -197,6 +200,7 @@ macro_rules! val_at {
/// Functor for |x| x.$i
#[macro_export]
#[collapse_debuginfo(yes)]
macro_rules! at {
($idx:tt) => {
|t| t.$idx

View file

@ -1,3 +1,5 @@
#![type_length_limit = "3072"]
extern crate conduwuit_core as conduwuit;
extern crate rust_rocksdb as rocksdb;

View file

@ -1,3 +1,5 @@
#![type_length_limit = "49152"] //TODO: reduce me
pub(crate) mod clap;
mod logging;
mod mods;

View file

@ -1,3 +1,5 @@
#![type_length_limit = "32768"] //TODO: reduce me
mod layers;
mod request;
mod router;

View file

@ -1,3 +1,4 @@
#![type_length_limit = "2048"]
#![allow(refining_impl_trait)]
mod manager;

View file

@ -18,11 +18,7 @@ use std::{
};
use async_trait::async_trait;
use conduwuit::{
Err, PduEvent, Result, RoomVersion, Server,
utils::{MutexMap, TryFutureExtExt},
};
use futures::TryFutureExt;
use conduwuit::{Err, PduEvent, Result, RoomVersion, Server, utils::MutexMap};
use ruma::{
OwnedEventId, OwnedRoomId, RoomId, RoomVersionId,
events::room::create::RoomCreateEventContent,
@ -103,13 +99,8 @@ impl Service {
self.services.timeline.pdu_exists(&event_id).await
}
async fn event_fetch(&self, event_id: OwnedEventId) -> Option<Arc<PduEvent>> {
self.services
.timeline
.get_pdu(&event_id)
.map_ok(Arc::new)
.ok()
.await
async fn event_fetch(&self, event_id: OwnedEventId) -> Option<PduEvent> {
self.services.timeline.get_pdu(&event_id).await.ok()
}
}

View file

@ -110,12 +110,14 @@ pub async fn state_resolution<'a, StateSets>(
where
StateSets: Iterator<Item = &'a StateMap<OwnedEventId>> + Clone + Send,
{
let event_fetch = |event_id| self.event_fetch(event_id);
let event_exists = |event_id| self.event_exists(event_id);
state_res::resolve(
room_version,
state_sets,
auth_chain_sets,
&|event_id| self.event_fetch(event_id),
&|event_id| self.event_exists(event_id),
&event_fetch,
&event_exists,
automatic_width(),
)
.map_err(|e| err!(error!("State resolution failed: {e:?}")))

View file

@ -9,7 +9,7 @@ use conduwuit::{
Err, Error, PduEvent, Result, implement,
utils::{
IterStream,
future::BoolExt,
future::{BoolExt, TryExtExt},
math::usize_from_f64,
stream::{BroadbandExt, ReadyExt},
},
@ -36,7 +36,7 @@ use ruma::{
use tokio::sync::{Mutex, MutexGuard};
pub use self::pagination_token::PaginationToken;
use crate::{Dep, conduwuit::utils::TryFutureExtExt, rooms, sending};
use crate::{Dep, rooms, sending};
pub struct Service {
services: Services,
@ -141,7 +141,8 @@ pub async fn get_summary_and_children_local(
}
let children_pdus: Vec<_> = self
.get_stripped_space_child_events(current_room)
.get_space_child_events(current_room)
.map(PduEvent::into_stripped_spacechild_state_event)
.collect()
.await;
@ -235,10 +236,10 @@ async fn get_summary_and_children_federation(
/// Simply returns the stripped m.space.child events of a room
#[implement(Service)]
fn get_stripped_space_child_events<'a>(
fn get_space_child_events<'a>(
&'a self,
room_id: &'a RoomId,
) -> impl Stream<Item = Raw<HierarchySpaceChildEvent>> + Send + 'a {
) -> impl Stream<Item = PduEvent> + Send + 'a {
self.services
.state
.get_room_shortstatehash(room_id)
@ -246,6 +247,7 @@ fn get_stripped_space_child_events<'a>(
self.services
.state_accessor
.state_keys_with_ids(current_shortstatehash, &StateEventType::SpaceChild)
.boxed()
})
.map(Result::into_iter)
.map(IterStream::stream)
@ -256,8 +258,8 @@ fn get_stripped_space_child_events<'a>(
.timeline
.get_pdu(&event_id)
.map_ok(move |pdu| (state_key, pdu))
.await
.ok()
.await
})
.ready_filter_map(move |(state_key, pdu)| {
if let Ok(content) = pdu.get_content::<SpaceChildEventContent>() {
@ -266,13 +268,12 @@ fn get_stripped_space_child_events<'a>(
}
}
if RoomId::parse(&state_key).is_ok() {
return Some(pdu);
if RoomId::parse(&state_key).is_err() {
return None;
}
None
Some(pdu)
})
.map(PduEvent::into_stripped_spacechild_state_event)
}
/// Gets the summary of a space using either local or remote (federation)
@ -501,7 +502,8 @@ async fn cache_insert(
allowed_room_ids,
room_id: room_id.clone(),
children_state: self
.get_stripped_space_child_events(&room_id)
.get_space_child_events(&room_id)
.map(PduEvent::into_stripped_spacechild_state_event)
.collect()
.await,
};

View file

@ -31,7 +31,7 @@ pub fn room_state_full<'a>(
self.services
.state
.get_room_shortstatehash(room_id)
.map_ok(|shortstatehash| self.state_full(shortstatehash).map(Ok))
.map_ok(|shortstatehash| self.state_full(shortstatehash).map(Ok).boxed())
.map_err(move |e| err!(Database("Missing state for {room_id:?}: {e:?}")))
.try_flatten_stream()
}
@ -46,7 +46,7 @@ pub fn room_state_full_pdus<'a>(
self.services
.state
.get_room_shortstatehash(room_id)
.map_ok(|shortstatehash| self.state_full_pdus(shortstatehash).map(Ok))
.map_ok(|shortstatehash| self.state_full_pdus(shortstatehash).map(Ok).boxed())
.map_err(move |e| err!(Database("Missing state for {room_id:?}: {e:?}")))
.try_flatten_stream()
}

View file

@ -235,6 +235,7 @@ pub fn state_keys_with_shortids<'a>(
.ignore_err()
.unzip()
.map(|(ssks, sids): (Vec<u64>, Vec<u64>)| (ssks, sids))
.boxed()
.shared();
let shortstatekeys = short_ids
@ -390,8 +391,10 @@ pub fn state_full_shortids(
.map(parse_compressed_state_event)
.collect()
})
.map_ok(|vec: Vec<_>| vec.into_iter().try_stream())
.map_ok(Vec::into_iter)
.map_ok(IterStream::try_stream)
.try_flatten_stream()
.boxed()
}
#[implement(super::Service)]