JMAP protocol layer refactoring (part 5)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*/
|
||||
|
||||
use jmap_tools::{Element, Property, Value};
|
||||
use std::{borrow::Borrow, str::FromStr, time::SystemTime};
|
||||
use utils::codec::{
|
||||
base32_custom::{Base32Reader, Base32Writer},
|
||||
@@ -240,3 +241,9 @@ impl std::fmt::Display for BlobId {
|
||||
f.write_str(&writer.finalize())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'x, P: Property, E: Element + From<BlobId>> From<BlobId> for Value<'x, P, E> {
|
||||
fn from(id: BlobId) -> Self {
|
||||
Value::Element(E::from(id))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
use crate::DocumentId;
|
||||
use jmap_tools::{Element, Property, Value};
|
||||
use std::{ops::Deref, str::FromStr};
|
||||
use utils::codec::base32_custom::{BASE32_ALPHABET, BASE32_INVERSE};
|
||||
|
||||
@@ -205,6 +206,12 @@ impl std::fmt::Display for Id {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'x, P: Property, E: Element + From<Id>> From<Id> for Value<'x, P, E> {
|
||||
fn from(id: Id) -> Self {
|
||||
Value::Element(E::from(id))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::str::FromStr;
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
use std::fmt::Display;
|
||||
|
||||
use jmap_tools::{Element, Property, Value};
|
||||
|
||||
pub const SEEN: usize = 0;
|
||||
pub const DRAFT: usize = 1;
|
||||
pub const FLAGGED: usize = 2;
|
||||
@@ -261,3 +263,9 @@ impl<'de> serde::Deserialize<'de> for Keyword {
|
||||
Ok(Keyword::parse(<&str>::deserialize(deserializer)?))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'x, P: Property, E: Element + From<Keyword>> From<Keyword> for Value<'x, P, E> {
|
||||
fn from(id: Keyword) -> Self {
|
||||
Value::Element(E::from(id))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*/
|
||||
|
||||
use jmap_tools::{Element, Property, Value};
|
||||
use utils::config::utils::ParseValue;
|
||||
|
||||
#[derive(
|
||||
@@ -98,3 +99,9 @@ impl ParseValue for SpecialUse {
|
||||
SpecialUse::parse(value).ok_or_else(|| format!("Unknown folder role {:?}", value))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'x, P: Property, E: Element + From<SpecialUse>> From<SpecialUse> for Value<'x, P, E> {
|
||||
fn from(id: SpecialUse) -> Self {
|
||||
Value::Element(E::from(id))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
use crate::collection::SyncCollection;
|
||||
use jmap_tools::{Element, Property, Value};
|
||||
use serde::Serialize;
|
||||
use std::{fmt::Display, str::FromStr};
|
||||
use utils::map::bitmap::{Bitmap, BitmapItem};
|
||||
@@ -222,3 +223,9 @@ impl<'de> serde::Deserialize<'de> for DataType {
|
||||
.ok_or_else(|| serde::de::Error::custom("invalid JMAP data type"))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'x, P: Property, E: Element + From<DataType>> From<DataType> for Value<'x, P, E> {
|
||||
fn from(id: DataType) -> Self {
|
||||
Value::Element(E::from(id))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user