refactor dyn KvTree out of services
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
57acc4f655
commit
cb48e25783
69 changed files with 594 additions and 647 deletions
|
@ -1,20 +1,21 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use database::KvTree;
|
||||
use conduit::{utils, Result};
|
||||
use database::{Database, Map};
|
||||
use ruma::RoomId;
|
||||
|
||||
use crate::{services, utils, KeyValueDatabase, Result};
|
||||
use crate::services;
|
||||
|
||||
type SearchPdusResult<'a> = Result<Option<(Box<dyn Iterator<Item = Vec<u8>> + 'a>, Vec<String>)>>;
|
||||
|
||||
pub struct Data {
|
||||
tokenids: Arc<dyn KvTree>,
|
||||
pub(super) struct Data {
|
||||
tokenids: Arc<Map>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
|
||||
pub(super) fn new(db: &Arc<Database>) -> Self {
|
||||
Self {
|
||||
tokenids: db.tokenids.clone(),
|
||||
tokenids: db["tokenids"].clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,18 @@
|
|||
use conduit::Server;
|
||||
use database::KeyValueDatabase;
|
||||
|
||||
mod data;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use conduit::{Result, Server};
|
||||
use data::Data;
|
||||
use database::Database;
|
||||
use ruma::RoomId;
|
||||
|
||||
use crate::Result;
|
||||
|
||||
pub struct Service {
|
||||
pub db: Data,
|
||||
db: Data,
|
||||
}
|
||||
|
||||
impl Service {
|
||||
pub fn build(_server: &Arc<Server>, db: &Arc<KeyValueDatabase>) -> Result<Self> {
|
||||
pub fn build(_server: &Arc<Server>, db: &Arc<Database>) -> Result<Self> {
|
||||
Ok(Self {
|
||||
db: Data::new(db),
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue