Moved data registry to separate module.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1m25s
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1m25s
This commit is contained in:
30
src/name.rs
30
src/name.rs
@@ -1,8 +1,4 @@
|
||||
use crate::{
|
||||
data_director::{Include, Path},
|
||||
message::Route,
|
||||
mtterror::MTTError,
|
||||
};
|
||||
use crate::mtterror::MTTError;
|
||||
use isolang::Language;
|
||||
use std::collections::HashMap;
|
||||
use uuid::Uuid;
|
||||
@@ -142,30 +138,6 @@ impl Names {
|
||||
NameType::None => Ok(Uuid::nil()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn path_to_route(&self, path: &Path) -> Result<Route, MTTError> {
|
||||
let doc_id = match &path.doc {
|
||||
Include::Just(id_info) => match id_info {
|
||||
NameType::ID(id) => {
|
||||
if self.ids.contains_key(&id) {
|
||||
Include::Just(id.clone())
|
||||
} else {
|
||||
return Err(MTTError::NameInvalidID(id.clone()));
|
||||
}
|
||||
}
|
||||
NameType::Name(name) => {
|
||||
let id = match self.get_id(name) {
|
||||
Ok(data) => data,
|
||||
Err(err) => return Err(err),
|
||||
};
|
||||
Include::Just(id.clone())
|
||||
}
|
||||
NameType::None => Include::Just(Uuid::nil()),
|
||||
},
|
||||
Include::All => Include::All,
|
||||
};
|
||||
Ok(Route::new(path.msg_id.clone(), doc_id, path.action.clone()))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user