Authenticate using registry - part 3

This commit is contained in:
mdecimus
2026-02-06 18:50:59 +01:00
parent 1a780ca294
commit 22e5f5a5ab
62 changed files with 2549 additions and 2156 deletions

View File

@@ -516,7 +516,7 @@ impl InMemoryStore {
}
}
pub fn as_store(&self) -> Option<&Store> {
pub fn into_store(self) -> Option<Store> {
match self {
InMemoryStore::Store(store) => Some(store),
_ => None,

View File

@@ -11,11 +11,19 @@ use registry::{
};
impl RegistryStore {
pub async fn get<T: ObjectType>(&self, id: Id) -> trc::Result<Option<T>> {
pub async fn id<T: ObjectType>(&self, id: Id) -> trc::Result<Option<T>> {
todo!()
}
pub async fn insert<T: ObjectType>(&self, object: &T) -> trc::Result<bool> {
pub async fn object<T: ObjectType>(&self, id: impl Into<u64>) -> trc::Result<Option<T>> {
self.id(Id::new(T::object(), id.into())).await
}
pub async fn singleton<T: ObjectType>(&self) -> trc::Result<Option<T>> {
self.id(T::object().singleton()).await
}
pub async fn insert<T: ObjectType>(&self, object: &T) -> trc::Result<Id> {
todo!()
}

View File

@@ -43,7 +43,7 @@ impl Bootstrap {
pub async fn setting<T: ObjectType>(&mut self) -> trc::Result<T> {
let object_id = T::object().singleton();
if let Some(setting) = self.registry.get::<T>(object_id).await? {
if let Some(setting) = self.registry.id::<T>(object_id).await? {
let mut errors = Vec::new();
if setting.validate(&mut errors) {
return Ok(setting);
@@ -72,7 +72,7 @@ impl Bootstrap {
pub async fn get_infallible<T: ObjectType>(&mut self, id: Id) -> Option<T> {
if id.object() != T::object() {
match self.registry.get::<T>(id).await {
match self.registry.id::<T>(id).await {
Ok(Some(setting)) => {
let mut errors = Vec::new();
if setting.validate(&mut errors) {