Improved object serialization
This commit is contained in:
@@ -9,14 +9,13 @@ use utils::map::vec_map::VecMap;
|
||||
|
||||
use crate::{
|
||||
error::set::SetError,
|
||||
object::Object,
|
||||
parser::{json::Parser, JsonObjectParser, Token},
|
||||
request::{method::MethodObject, reference::MaybeReference, RequestProperty},
|
||||
parser::{JsonObjectParser, Token, json::Parser},
|
||||
request::{RequestProperty, method::MethodObject, reference::MaybeReference},
|
||||
types::{
|
||||
blob::BlobId,
|
||||
id::Id,
|
||||
state::{State, StateChange},
|
||||
value::{SetValue, Value},
|
||||
value::{Object, SetValue, Value},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -98,7 +97,7 @@ impl JsonObjectParser for CopyRequest<RequestArguments> {
|
||||
_ => {
|
||||
return Err(trc::JmapEvent::UnknownMethod
|
||||
.into_err()
|
||||
.details(format!("{}/copy", parser.ctx)))
|
||||
.details(format!("{}/copy", parser.ctx)));
|
||||
}
|
||||
},
|
||||
account_id: Id::default(),
|
||||
|
||||
@@ -5,14 +5,21 @@
|
||||
*/
|
||||
|
||||
use crate::{
|
||||
object::{blob, email, Object},
|
||||
parser::{json::Parser, JsonObjectParser, Token},
|
||||
object::{blob, email},
|
||||
parser::{JsonObjectParser, Token, json::Parser},
|
||||
request::{
|
||||
RequestProperty, RequestPropertyParser,
|
||||
method::MethodObject,
|
||||
reference::{MaybeReference, ResultReference},
|
||||
RequestProperty, RequestPropertyParser,
|
||||
},
|
||||
types::{any_id::AnyId, blob::BlobId, id::Id, property::Property, state::State, value::Value},
|
||||
types::{
|
||||
any_id::AnyId,
|
||||
blob::BlobId,
|
||||
id::Id,
|
||||
property::Property,
|
||||
state::State,
|
||||
value::{Object, Value},
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -74,7 +81,7 @@ impl JsonObjectParser for GetRequest<RequestArguments> {
|
||||
_ => {
|
||||
return Err(trc::JmapEvent::UnknownMethod
|
||||
.into_err()
|
||||
.details(format!("{}/get", parser.ctx)))
|
||||
.details(format!("{}/get", parser.ctx)));
|
||||
}
|
||||
},
|
||||
account_id: Id::default(),
|
||||
|
||||
@@ -8,11 +8,10 @@ use utils::map::vec_map::VecMap;
|
||||
|
||||
use crate::{
|
||||
error::set::SetError,
|
||||
object::Object,
|
||||
parser::{json::Parser, JsonObjectParser, Token},
|
||||
parser::{JsonObjectParser, Token, json::Parser},
|
||||
request::{
|
||||
reference::{MaybeReference, ResultReference},
|
||||
RequestProperty,
|
||||
reference::{MaybeReference, ResultReference},
|
||||
},
|
||||
response::Response,
|
||||
types::{
|
||||
@@ -22,7 +21,7 @@ use crate::{
|
||||
keyword::Keyword,
|
||||
property::Property,
|
||||
state::{State, StateChange},
|
||||
value::{SetValueMap, Value},
|
||||
value::{Object, SetValueMap, Value},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -7,10 +7,14 @@
|
||||
use utils::map::vec_map::VecMap;
|
||||
|
||||
use crate::{
|
||||
object::Object,
|
||||
parser::{json::Parser, Ignore, JsonObjectParser, Token},
|
||||
parser::{Ignore, JsonObjectParser, Token, json::Parser},
|
||||
request::RequestProperty,
|
||||
types::{blob::BlobId, id::Id, property::Property, value::Value},
|
||||
types::{
|
||||
blob::BlobId,
|
||||
id::Id,
|
||||
property::Property,
|
||||
value::{Object, Value},
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
@@ -9,12 +9,12 @@ use utils::map::{bitmap::Bitmap, vec_map::VecMap};
|
||||
|
||||
use crate::{
|
||||
error::set::{InvalidProperty, SetError},
|
||||
object::{email_submission, mailbox, sieve, Object},
|
||||
parser::{json::Parser, JsonObjectParser, Token},
|
||||
object::{email_submission, mailbox, sieve},
|
||||
parser::{JsonObjectParser, Token, json::Parser},
|
||||
request::{
|
||||
RequestProperty, RequestPropertyParser,
|
||||
method::MethodObject,
|
||||
reference::{MaybeReference, ResultReference},
|
||||
RequestProperty, RequestPropertyParser,
|
||||
},
|
||||
response::Response,
|
||||
types::{
|
||||
@@ -26,7 +26,7 @@ use crate::{
|
||||
keyword::Keyword,
|
||||
property::{HeaderForm, ObjectProperty, Property, SetProperty},
|
||||
state::{State, StateChange},
|
||||
value::{SetValue, SetValueMap, Value},
|
||||
value::{Object, SetValue, SetValueMap, Value},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -114,7 +114,7 @@ impl JsonObjectParser for SetRequest<RequestArguments> {
|
||||
_ => {
|
||||
return Err(trc::JmapEvent::UnknownMethod
|
||||
.into_err()
|
||||
.details(format!("{}/set", parser.ctx)))
|
||||
.details(format!("{}/set", parser.ctx)));
|
||||
}
|
||||
},
|
||||
account_id: Id::default(),
|
||||
@@ -168,9 +168,7 @@ impl JsonObjectParser for Object<SetValue> {
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
let mut obj = Object {
|
||||
properties: VecMap::with_capacity(8),
|
||||
};
|
||||
let mut obj = Object(VecMap::with_capacity(8));
|
||||
|
||||
parser
|
||||
.next_token::<String>()?
|
||||
@@ -348,7 +346,7 @@ impl JsonObjectParser for Object<SetValue> {
|
||||
SetValue::ResultReference(ResultReference::parse(parser)?)
|
||||
};
|
||||
|
||||
obj.properties.append(key.property, value);
|
||||
obj.0.append(key.property, value);
|
||||
}
|
||||
|
||||
Ok(obj)
|
||||
@@ -536,7 +534,7 @@ impl SetResponse {
|
||||
(&mut self.created)
|
||||
.into_iter()
|
||||
.map(|(_, obj)| obj)
|
||||
.find(|obj| obj.properties.get(&Property::Id) == Some(&Value::Id(id)))
|
||||
.find(|obj| obj.0.get(&Property::Id) == Some(&Value::Id(id)))
|
||||
}
|
||||
|
||||
pub fn has_changes(&self) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user