JMAP Registry API implementation - part 12
This commit is contained in:
@@ -21,7 +21,7 @@ pub use crate::types::datetime::UTCDateTime;
|
||||
pub use crate::types::duration::Duration;
|
||||
pub use crate::types::error::*;
|
||||
pub use crate::types::float::Float;
|
||||
pub use crate::types::index::IndexBuilder;
|
||||
pub use crate::types::index::{IndexBuilder, IndexSchema, IndexSchemaType, IndexSchemaValueType};
|
||||
pub use crate::types::ipaddr::IpAddr;
|
||||
pub use crate::types::ipmask::IpAddrOrMask;
|
||||
pub use crate::types::list::List;
|
||||
|
||||
@@ -46,6 +46,31 @@ pub enum IndexValue<'x> {
|
||||
None,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct IndexSchema {
|
||||
pub prop: Property,
|
||||
pub typ: IndexSchemaType,
|
||||
pub value: IndexSchemaValueType,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[repr(u8)]
|
||||
pub enum IndexSchemaType {
|
||||
Unique,
|
||||
Search,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[repr(u8)]
|
||||
pub enum IndexSchemaValueType {
|
||||
Keyword,
|
||||
Text,
|
||||
Number,
|
||||
Enum,
|
||||
Boolean,
|
||||
Id,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
||||
pub struct IndexBuilder<'x> {
|
||||
@@ -135,6 +160,12 @@ impl<'x> IndexBuilder<'x> {
|
||||
}
|
||||
}
|
||||
|
||||
impl IndexSchema {
|
||||
pub const fn new(prop: Property, typ: IndexSchemaType, value: IndexSchemaValueType) -> Self {
|
||||
Self { prop, typ, value }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u64> for IndexValue<'_> {
|
||||
fn from(value: u64) -> Self {
|
||||
IndexValue::U64(value)
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*/
|
||||
|
||||
use crate::schema::prelude::{Task, TaskStatus, TaskStatusPending, UTCDateTime};
|
||||
use crate::schema::{
|
||||
enums::Permission,
|
||||
prelude::{Action, Task, TaskStatus, TaskStatusPending, UTCDateTime},
|
||||
};
|
||||
|
||||
impl Task {
|
||||
pub fn set_status(&mut self, status: TaskStatus) {
|
||||
@@ -60,6 +63,41 @@ impl Task {
|
||||
TaskStatus::Failed(_) => u64::MAX,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn permission(&self) -> Permission {
|
||||
match self {
|
||||
Task::IndexDocument(_) => Permission::TaskIndexDocument,
|
||||
Task::UnindexDocument(_) => Permission::TaskUnindexDocument,
|
||||
Task::IndexTrace(_) => Permission::TaskIndexTrace,
|
||||
Task::CalendarAlarmEmail(_) => Permission::TaskCalendarAlarmEmail,
|
||||
Task::CalendarAlarmNotification(_) => Permission::TaskCalendarAlarmNotification,
|
||||
Task::CalendarItipMessage(_) => Permission::TaskCalendarItipMessage,
|
||||
Task::MergeThreads(_) => Permission::TaskMergeThreads,
|
||||
Task::DmarcReport(_) => Permission::TaskDmarcReport,
|
||||
Task::TlsReport(_) => Permission::TaskTlsReport,
|
||||
Task::RestoreArchivedItem(_) => Permission::TaskRestoreArchivedItem,
|
||||
Task::DestroyAccount(_) => Permission::TaskDestroyAccount,
|
||||
Task::AccountMaintenance(_) => Permission::TaskAccountMaintenance,
|
||||
Task::StoreMaintenance(_) => Permission::TaskStoreMaintenance,
|
||||
Task::SpamFilterMaintenance(_) => Permission::TaskSpamFilterMaintenance,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Action {
|
||||
pub fn permission(&self) -> Permission {
|
||||
match self {
|
||||
Action::ReloadSettings => Permission::ActionReloadSettings,
|
||||
Action::ReloadTlsCertificates => Permission::ActionReloadTlsCertificates,
|
||||
Action::ReloadLookupStores => Permission::ActionReloadLookupStores,
|
||||
Action::ReloadBlockedIps => Permission::ActionReloadBlockedIps,
|
||||
Action::TroubleshootDmarc(_) => Permission::ActionTroubleshootDmarc,
|
||||
Action::ClassifySpam(_) => Permission::ActionClassifySpam,
|
||||
Action::InvalidateCaches => Permission::ActionInvalidateCaches,
|
||||
Action::PauseMtaQueue => Permission::ActionPauseMtaQueue,
|
||||
Action::ResumeMtaQueue => Permission::ActionResumeMtaQueue,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TaskStatus {
|
||||
|
||||
Reference in New Issue
Block a user