pass args by ref

This commit is contained in:
dasha_uwu
2025-09-17 14:21:55 +05:00
committed by Jason Volk
parent d6e95c51c0
commit 9c4d376bec
43 changed files with 97 additions and 101 deletions

View File

@@ -28,7 +28,7 @@ struct Data {
}
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
db: Data {
alias_userid: args.db["alias_userid"].clone(),

View File

@@ -31,10 +31,10 @@ pub struct Service {
type Bucket<'a> = BTreeSet<(u64, &'a EventId)>;
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
services: args.services.clone(),
db: Data::new(&args),
db: Data::new(args),
}))
}

View File

@@ -17,7 +17,7 @@ pub struct Service {
}
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self { services: args.services.clone() }))
}

View File

@@ -14,7 +14,7 @@ struct Data {
}
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
db: Data {
publicroomids: args.db["publicroomids"].clone(),

View File

@@ -35,7 +35,7 @@ type RoomMutexMap = MutexMap<OwnedRoomId, ()>;
#[async_trait]
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
mutex_federation: RoomMutexMap::new(),
services: args.services.clone(),

View File

@@ -43,7 +43,7 @@ pub type Witness = HashSet<OwnedUserId>;
type Key<'a> = (&'a UserId, Option<&'a DeviceId>, &'a RoomId, &'a UserId);
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
db: Data {
lazyloadedids: args.db["lazyloadedids"].clone(),

View File

@@ -24,7 +24,7 @@ struct Data {
}
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
db: Data {
disabledroomids: args.db["disabledroomids"].clone(),

View File

@@ -16,10 +16,10 @@ pub struct Service {
}
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
services: args.services.clone(),
db: Data::new(&args),
db: Data::new(args),
}))
}

View File

@@ -28,10 +28,10 @@ pub struct Service {
}
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
services: args.services.clone(),
db: Data::new(&args),
db: Data::new(args),
}))
}

View File

@@ -45,7 +45,7 @@ const TOKEN_ID_MAX_LEN: usize =
const WORD_MAX_LEN: usize = 50;
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
db: Data { tokenids: args.db["tokenids"].clone() },
services: args.services.clone(),

View File

@@ -24,7 +24,7 @@ struct Data {
pub type ShortStateHash = ShortId;
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
db: Data {
eventid_shorteventid: args.db["eventid_shorteventid"].clone(),

View File

@@ -59,7 +59,7 @@ type Cache = LruCache<OwnedRoomId, Option<CachedSpaceHierarchySummary>>;
#[async_trait]
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
let config = &args.server.config;
let cache_size = f64::from(config.roomid_spacehierarchy_cache_capacity);
let cache_size = cache_size * config.cache_capacity_modifier;

View File

@@ -51,7 +51,7 @@ pub type RoomMutexGuard = MutexMapGuard<OwnedRoomId, ()>;
#[async_trait]
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
mutex: RoomMutexMap::new(),
services: args.services.clone(),

View File

@@ -44,7 +44,7 @@ struct Data {
#[async_trait]
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
services: args.services.clone(),
db: Data {

View File

@@ -52,7 +52,7 @@ type StrippedStateEventItem = (OwnedRoomId, Vec<Raw<AnyStrippedStateEvent>>);
type SyncStateEventItem = (OwnedRoomId, Vec<Raw<AnySyncStateEvent>>);
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
appservice_in_room_cache: RwLock::new(HashMap::new()),
services: args.services.clone(),

View File

@@ -60,7 +60,7 @@ pub type CompressedStateEvent = [u8; 2 * size_of::<ShortId>()];
#[async_trait]
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
let config = &args.server.config;
let cache_capacity =
f64::from(config.stateinfo_cache_capacity) * config.cache_capacity_modifier;

View File

@@ -27,7 +27,7 @@ pub(super) struct Data {
}
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
db: Data {
threadid_userids: args.db["threadid_userids"].clone(),

View File

@@ -79,7 +79,7 @@ pub type PdusIterItem = (PduCount, PduEvent);
#[async_trait]
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
services: args.services.clone(),
db: Data {

View File

@@ -24,7 +24,7 @@ pub struct Service {
}
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
server: args.server.clone(),
services: args.services.clone(),

View File

@@ -23,7 +23,7 @@ struct Data {
}
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
db: Data {
db: args.db.clone(),