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)] #![allow(clippy::toplevel_ref_arg)]
pub mod client; pub mod client;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -31,7 +31,7 @@ pub fn room_state_full<'a>(
self.services self.services
.state .state
.get_room_shortstatehash(room_id) .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:?}"))) .map_err(move |e| err!(Database("Missing state for {room_id:?}: {e:?}")))
.try_flatten_stream() .try_flatten_stream()
} }
@ -46,7 +46,7 @@ pub fn room_state_full_pdus<'a>(
self.services self.services
.state .state
.get_room_shortstatehash(room_id) .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:?}"))) .map_err(move |e| err!(Database("Missing state for {room_id:?}: {e:?}")))
.try_flatten_stream() .try_flatten_stream()
} }

View file

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