Fix clippy warnings across workspace
This commit is contained in:
parent
8310e10ca1
commit
c6aa2e0428
@ -36,7 +36,7 @@ impl Meta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for Meta {
|
impl Parse for Meta {
|
||||||
fn parse(input: ParseStream) -> syn::Result<Self> {
|
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
|
||||||
let ident = input.parse()?;
|
let ident = input.parse()?;
|
||||||
|
|
||||||
if input.peek(Token![=]) {
|
if input.peek(Token![=]) {
|
||||||
|
@ -128,7 +128,7 @@ enum Field {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for Field {
|
impl Parse for Field {
|
||||||
fn parse(input: ParseStream) -> syn::Result<Self> {
|
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
|
||||||
let lookahead = input.lookahead1();
|
let lookahead = input.lookahead1();
|
||||||
|
|
||||||
if lookahead.peek(kw::description) {
|
if lookahead.peek(kw::description) {
|
||||||
@ -165,7 +165,7 @@ enum FieldValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for FieldValue {
|
impl Parse for FieldValue {
|
||||||
fn parse(input: ParseStream) -> syn::Result<Self> {
|
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
|
||||||
let attrs: Vec<Attribute> = input.call(Attribute::parse_outer)?;
|
let attrs: Vec<Attribute> = input.call(Attribute::parse_outer)?;
|
||||||
for attr in attrs.iter() {
|
for attr in attrs.iter() {
|
||||||
if !util::is_cfg_attribute(attr) {
|
if !util::is_cfg_attribute(attr) {
|
||||||
|
@ -313,8 +313,8 @@ fn collect_lifetime_idents(lifetimes: &mut BTreeSet<Lifetime>, ty: &Type) {
|
|||||||
|
|
||||||
fn req_res_meta_word<T>(
|
fn req_res_meta_word<T>(
|
||||||
attr_kind: &str,
|
attr_kind: &str,
|
||||||
field: &syn::Field,
|
field: &Field,
|
||||||
newtype_body_field: &mut Option<syn::Field>,
|
newtype_body_field: &mut Option<Field>,
|
||||||
body_field_kind: T,
|
body_field_kind: T,
|
||||||
raw_field_kind: T,
|
raw_field_kind: T,
|
||||||
) -> syn::Result<T> {
|
) -> syn::Result<T> {
|
||||||
|
@ -168,7 +168,7 @@ impl AsRef<str> for ErrorKind {
|
|||||||
Self::Exclusive => "M_EXCLUSIVE",
|
Self::Exclusive => "M_EXCLUSIVE",
|
||||||
Self::ResourceLimitExceeded { .. } => "M_RESOURCE_LIMIT_EXCEEDED",
|
Self::ResourceLimitExceeded { .. } => "M_RESOURCE_LIMIT_EXCEEDED",
|
||||||
Self::CannotLeaveServerNoticeRoom => "M_CANNOT_LEAVE_SERVER_NOTICE_ROOM",
|
Self::CannotLeaveServerNoticeRoom => "M_CANNOT_LEAVE_SERVER_NOTICE_ROOM",
|
||||||
Self::_Custom { errcode, .. } => &errcode,
|
Self::_Custom { errcode, .. } => errcode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ impl EndpointError for Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Error {
|
impl fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "[{} / {}] {}", self.status_code.as_u16(), self.kind, self.message)
|
write!(f, "[{} / {}] {}", self.status_code.as_u16(), self.kind, self.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ impl<'de> Deserialize<'de> for Field<'de> {
|
|||||||
impl<'de> Visitor<'de> for FieldVisitor {
|
impl<'de> Visitor<'de> for FieldVisitor {
|
||||||
type Value = Field<'de>;
|
type Value = Field<'de>;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
formatter.write_str("any struct field")
|
formatter.write_str("any struct field")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ struct ErrorKindVisitor;
|
|||||||
impl<'de> Visitor<'de> for ErrorKindVisitor {
|
impl<'de> Visitor<'de> for ErrorKindVisitor {
|
||||||
type Value = ErrorKind;
|
type Value = ErrorKind;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
formatter.write_str("enum ErrorKind")
|
formatter.write_str("enum ErrorKind")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,12 +100,12 @@ impl<'de> Visitor<'de> for ErrorKindVisitor {
|
|||||||
|
|
||||||
macro_rules! set_field {
|
macro_rules! set_field {
|
||||||
(errcode) => {
|
(errcode) => {
|
||||||
set_field!(@inner errcode);
|
set_field!(@inner errcode)
|
||||||
};
|
};
|
||||||
($field:ident) => {
|
($field:ident) => {
|
||||||
match errcode {
|
match errcode {
|
||||||
Some(set_field!(@variant_containing $field)) | None => {
|
Some(set_field!(@variant_containing $field)) | None => {
|
||||||
set_field!(@inner $field);
|
set_field!(@inner $field)
|
||||||
}
|
}
|
||||||
// if we already know we're deserializing a different variant to the one
|
// if we already know we're deserializing a different variant to the one
|
||||||
// containing this field, ignore its value.
|
// containing this field, ignore its value.
|
||||||
@ -249,7 +249,7 @@ enum ErrCode {
|
|||||||
impl<'de> Deserialize<'de> for ErrorKind {
|
impl<'de> Deserialize<'de> for ErrorKind {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: serde::Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
{
|
{
|
||||||
deserializer.deserialize_map(ErrorKindVisitor)
|
deserializer.deserialize_map(ErrorKindVisitor)
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ impl Capabilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator over the capabilities.
|
/// Returns an iterator over the capabilities.
|
||||||
pub fn iter(&self) -> CapabilitiesIter {
|
pub fn iter(&self) -> CapabilitiesIter<'_> {
|
||||||
CapabilitiesIter::new(self)
|
CapabilitiesIter::new(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ impl From<PushRule> for SimplePushRule {
|
|||||||
pub struct MissingPatternError;
|
pub struct MissingPatternError;
|
||||||
|
|
||||||
impl fmt::Display for MissingPatternError {
|
impl fmt::Display for MissingPatternError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "Push rule does not have a pattern.")
|
write!(f, "Push rule does not have a pattern.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ impl TryFrom<PushRule> for PatternedPushRule {
|
|||||||
pub struct MissingConditionsError;
|
pub struct MissingConditionsError;
|
||||||
|
|
||||||
impl fmt::Display for MissingConditionsError {
|
impl fmt::Display for MissingConditionsError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "Push rule has no conditions.")
|
write!(f, "Push rule has no conditions.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ struct LoginTypeDeHelper {
|
|||||||
type_: String,
|
type_: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de> de::Deserialize<'de> for LoginType {
|
impl<'de> Deserialize<'de> for LoginType {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: de::Deserializer<'de>,
|
D: de::Deserializer<'de>,
|
||||||
|
@ -77,7 +77,7 @@ impl Response {
|
|||||||
|
|
||||||
/// Identification information for the user.
|
/// Identification information for the user.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Outgoing, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Outgoing, Serialize)]
|
||||||
#[serde(from = "user_serde::IncomingUserIdentifier", into = "user_serde::UserIdentifier")]
|
#[serde(from = "user_serde::IncomingUserIdentifier", into = "user_serde::UserIdentifier<'_>")]
|
||||||
pub enum UserIdentifier<'a> {
|
pub enum UserIdentifier<'a> {
|
||||||
/// Either a fully qualified Matrix user ID, or just the localpart (as part of the 'identifier'
|
/// Either a fully qualified Matrix user ID, or just the localpart (as part of the 'identifier'
|
||||||
/// field).
|
/// field).
|
||||||
|
@ -84,7 +84,7 @@ impl<'a> ruma_api::OutgoingRequest for Request<'a> {
|
|||||||
|
|
||||||
if !self.state_key.is_empty() {
|
if !self.state_key.is_empty() {
|
||||||
url.push('/');
|
url.push('/');
|
||||||
url.push_str(&Cow::from(utf8_percent_encode(&self.state_key, NON_ALPHANUMERIC)));
|
url.push_str(&Cow::from(utf8_percent_encode(self.state_key, NON_ALPHANUMERIC)));
|
||||||
}
|
}
|
||||||
|
|
||||||
http::Request::builder()
|
http::Request::builder()
|
||||||
|
@ -94,7 +94,7 @@ impl<'a> ruma_api::OutgoingRequest for Request<'a> {
|
|||||||
// Last URL segment is optional, that is why this trait impl is not generated.
|
// Last URL segment is optional, that is why this trait impl is not generated.
|
||||||
if !self.state_key.is_empty() {
|
if !self.state_key.is_empty() {
|
||||||
url.push('/');
|
url.push('/');
|
||||||
url.push_str(&Cow::from(utf8_percent_encode(&self.state_key, NON_ALPHANUMERIC)));
|
url.push_str(&Cow::from(utf8_percent_encode(self.state_key, NON_ALPHANUMERIC)));
|
||||||
}
|
}
|
||||||
|
|
||||||
let http_request = http::Request::builder()
|
let http_request = http::Request::builder()
|
||||||
|
@ -838,7 +838,7 @@ mod server_tests {
|
|||||||
|
|
||||||
assert_matches!(req.filter, Some(IncomingFilter::FilterId(id)) if id == "myfilter");
|
assert_matches!(req.filter, Some(IncomingFilter::FilterId(id)) if id == "myfilter");
|
||||||
assert_eq!(req.since, Some("myts".into()));
|
assert_eq!(req.since, Some("myts".into()));
|
||||||
assert_eq!(req.full_state, false);
|
assert!(!req.full_state);
|
||||||
assert_eq!(req.set_presence, PresenceState::Offline);
|
assert_eq!(req.set_presence, PresenceState::Offline);
|
||||||
assert_eq!(req.timeout, Some(Duration::from_millis(5000)));
|
assert_eq!(req.timeout, Some(Duration::from_millis(5000)));
|
||||||
}
|
}
|
||||||
@ -859,7 +859,7 @@ mod server_tests {
|
|||||||
|
|
||||||
assert_matches!(req.filter, None);
|
assert_matches!(req.filter, None);
|
||||||
assert_eq!(req.since, None);
|
assert_eq!(req.since, None);
|
||||||
assert_eq!(req.full_state, false);
|
assert!(!req.full_state);
|
||||||
assert_eq!(req.set_presence, PresenceState::Online);
|
assert_eq!(req.set_presence, PresenceState::Online);
|
||||||
assert_eq!(req.timeout, None);
|
assert_eq!(req.timeout, None);
|
||||||
}
|
}
|
||||||
@ -884,7 +884,7 @@ mod server_tests {
|
|||||||
|
|
||||||
assert_matches!(req.filter, Some(IncomingFilter::FilterId(id)) if id == "EOKFFmdZYF");
|
assert_matches!(req.filter, Some(IncomingFilter::FilterId(id)) if id == "EOKFFmdZYF");
|
||||||
assert_eq!(req.since, None);
|
assert_eq!(req.since, None);
|
||||||
assert_eq!(req.full_state, false);
|
assert!(!req.full_state);
|
||||||
assert_eq!(req.set_presence, PresenceState::Online);
|
assert_eq!(req.set_presence, PresenceState::Online);
|
||||||
assert_eq!(req.timeout, Some(Duration::from_millis(0)));
|
assert_eq!(req.timeout, Some(Duration::from_millis(0)));
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ edition = "2018"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
indexmap = { version = "1.6.2", features = ["serde-1"] }
|
indexmap = { version = "1.6.2", features = ["serde-1"] }
|
||||||
js_int = { version = "0.2.0", features = ["serde"] }
|
js_int = { version = "0.2.0", features = ["serde"] }
|
||||||
maplit = "1.0.2"
|
|
||||||
ruma-identifiers = { version = "0.19.0", path = "../ruma-identifiers" }
|
ruma-identifiers = { version = "0.19.0", path = "../ruma-identifiers" }
|
||||||
ruma-serde = { version = "0.3.1", path = "../ruma-serde" }
|
ruma-serde = { version = "0.3.1", path = "../ruma-serde" }
|
||||||
serde = { version = "1.0.118", features = ["derive"] }
|
serde = { version = "1.0.118", features = ["derive"] }
|
||||||
@ -23,6 +22,7 @@ wildmatch = "2.0.0"
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
matches = "0.1.8"
|
matches = "0.1.8"
|
||||||
|
maplit = "1.0.2"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
compat = []
|
compat = []
|
||||||
|
@ -181,7 +181,7 @@ struct RoomNetworkVisitor;
|
|||||||
impl<'de> Visitor<'de> for RoomNetworkVisitor {
|
impl<'de> Visitor<'de> for RoomNetworkVisitor {
|
||||||
type Value = IncomingRoomNetwork;
|
type Value = IncomingRoomNetwork;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
formatter.write_str("Network selection")
|
formatter.write_str("Network selection")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ impl Ruleset {
|
|||||||
/// Creates a borrowing iterator over all push rules in this `Ruleset`.
|
/// Creates a borrowing iterator over all push rules in this `Ruleset`.
|
||||||
///
|
///
|
||||||
/// For an owning iterator, use `.into_iter()`.
|
/// For an owning iterator, use `.into_iter()`.
|
||||||
pub fn iter(&self) -> RulesetIter {
|
pub fn iter(&self) -> RulesetIter<'_> {
|
||||||
self.into_iter()
|
self.into_iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ impl<'de> Deserialize<'de> for Action {
|
|||||||
"notify" => Ok(Action::Notify),
|
"notify" => Ok(Action::Notify),
|
||||||
"dont_notify" => Ok(Action::DontNotify),
|
"dont_notify" => Ok(Action::DontNotify),
|
||||||
"coalesce" => Ok(Action::Coalesce),
|
"coalesce" => Ok(Action::Coalesce),
|
||||||
s => Err(E::unknown_variant(&s, &["notify", "dont_notify", "coalesce"])),
|
s => Err(E::unknown_variant(s, &["notify", "dont_notify", "coalesce"])),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ impl PushCondition {
|
|||||||
/// * `context` - The context of the room at the time of the event.
|
/// * `context` - The context of the room at the time of the event.
|
||||||
pub fn applies(&self, event: &FlattenedJson, context: &PushConditionRoomCtx) -> bool {
|
pub fn applies(&self, event: &FlattenedJson, context: &PushConditionRoomCtx) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::EventMatch { key, pattern } => check_event_match(event, &key, &pattern, context),
|
Self::EventMatch { key, pattern } => check_event_match(event, key, pattern, context),
|
||||||
Self::ContainsDisplayName => {
|
Self::ContainsDisplayName => {
|
||||||
let value = match event.get("content.body") {
|
let value = match event.get("content.body") {
|
||||||
Some(v) => v,
|
Some(v) => v,
|
||||||
|
@ -28,11 +28,11 @@ impl AnyPushRule {
|
|||||||
/// Convert `AnyPushRule` to `AnyPushRuleRef`.
|
/// Convert `AnyPushRule` to `AnyPushRuleRef`.
|
||||||
pub fn as_ref(&self) -> AnyPushRuleRef<'_> {
|
pub fn as_ref(&self) -> AnyPushRuleRef<'_> {
|
||||||
match self {
|
match self {
|
||||||
Self::Override(o) => AnyPushRuleRef::Override(&o),
|
Self::Override(o) => AnyPushRuleRef::Override(o),
|
||||||
Self::Content(c) => AnyPushRuleRef::Content(&c),
|
Self::Content(c) => AnyPushRuleRef::Content(c),
|
||||||
Self::Room(r) => AnyPushRuleRef::Room(&r),
|
Self::Room(r) => AnyPushRuleRef::Room(r),
|
||||||
Self::Sender(s) => AnyPushRuleRef::Sender(&s),
|
Self::Sender(s) => AnyPushRuleRef::Sender(s),
|
||||||
Self::Underride(u) => AnyPushRuleRef::Underride(&u),
|
Self::Underride(u) => AnyPushRuleRef::Underride(u),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ fn expand_deserialize_event(
|
|||||||
},
|
},
|
||||||
#ruma_events::HasDeserializeFields::Optional => {
|
#ruma_events::HasDeserializeFields::Optional => {
|
||||||
let json = content.unwrap_or(
|
let json = content.unwrap_or(
|
||||||
#serde_json::value::RawValue::from_string("{}".to_string())
|
#serde_json::value::RawValue::from_string("{}".to_owned())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
);
|
);
|
||||||
C::from_parts(&event_type, json).map_err(A::Error::custom)?
|
C::from_parts(&event_type, json).map_err(A::Error::custom)?
|
||||||
|
@ -41,7 +41,7 @@ impl EventMeta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for EventMeta {
|
impl Parse for EventMeta {
|
||||||
fn parse(input: ParseStream) -> syn::Result<Self> {
|
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
|
||||||
let lookahead = input.lookahead1();
|
let lookahead = input.lookahead1();
|
||||||
if lookahead.peek(Token![type]) {
|
if lookahead.peek(Token![type]) {
|
||||||
let _: Token![type] = input.parse()?;
|
let _: Token![type] = input.parse()?;
|
||||||
@ -72,7 +72,7 @@ impl MetaAttrs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for MetaAttrs {
|
impl Parse for MetaAttrs {
|
||||||
fn parse(input: ParseStream) -> syn::Result<Self> {
|
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
|
||||||
let attrs = syn::punctuated::Punctuated::<EventMeta, Token![,]>::parse_terminated(input)?;
|
let attrs = syn::punctuated::Punctuated::<EventMeta, Token![,]>::parse_terminated(input)?;
|
||||||
Ok(Self(attrs.into_iter().collect()))
|
Ok(Self(attrs.into_iter().collect()))
|
||||||
}
|
}
|
||||||
|
@ -177,13 +177,13 @@ fn expand_any_with_deser(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let event_enum_to_from_sync = expand_conversion_impl(kind, var, &variants, ruma_events);
|
let event_enum_to_from_sync = expand_conversion_impl(kind, var, variants, ruma_events);
|
||||||
|
|
||||||
let redacted_enum = expand_redacted_enum(kind, var, ruma_events);
|
let redacted_enum = expand_redacted_enum(kind, var, ruma_events);
|
||||||
|
|
||||||
let field_accessor_impl = accessor_methods(kind, var, &variants, ruma_events);
|
let field_accessor_impl = accessor_methods(kind, var, variants, ruma_events);
|
||||||
|
|
||||||
let redact_impl = expand_redact(&ident, kind, var, &variants, ruma_events);
|
let redact_impl = expand_redact(&ident, kind, var, variants, ruma_events);
|
||||||
|
|
||||||
Some(quote! {
|
Some(quote! {
|
||||||
#any_enum
|
#any_enum
|
||||||
@ -428,7 +428,7 @@ fn expand_content_enum(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let marker_trait_impls = marker_traits(&kind, ruma_events);
|
let marker_trait_impls = marker_traits(kind, ruma_events);
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
#content_enum
|
#content_enum
|
||||||
|
@ -128,7 +128,7 @@ impl EventKind {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for EventKind {
|
impl Parse for EventKind {
|
||||||
fn parse(input: ParseStream) -> syn::Result<Self> {
|
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
|
||||||
let ident: Ident = input.parse()?;
|
let ident: Ident = input.parse()?;
|
||||||
Ok(match ident.to_string().as_str() {
|
Ok(match ident.to_string().as_str() {
|
||||||
"Basic" => EventKind::Basic,
|
"Basic" => EventKind::Basic,
|
||||||
|
@ -38,7 +38,7 @@ impl EventContent for CustomEventContent {
|
|||||||
|
|
||||||
fn from_parts(event_type: &str, content: Box<RawJsonValue>) -> Result<Self, serde_json::Error> {
|
fn from_parts(event_type: &str, content: Box<RawJsonValue>) -> Result<Self, serde_json::Error> {
|
||||||
let data = serde_json::from_str(content.get())?;
|
let data = serde_json::from_str(content.get())?;
|
||||||
Ok(Self { event_type: event_type.to_string(), data })
|
Ok(Self { event_type: event_type.to_owned(), data })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,13 +73,13 @@ impl EventContent for RedactedCustomEventContent {
|
|||||||
event_type: &str,
|
event_type: &str,
|
||||||
_content: Box<RawJsonValue>,
|
_content: Box<RawJsonValue>,
|
||||||
) -> Result<Self, serde_json::Error> {
|
) -> Result<Self, serde_json::Error> {
|
||||||
Ok(Self { event_type: event_type.to_string() })
|
Ok(Self { event_type: event_type.to_owned() })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RedactedEventContent for RedactedCustomEventContent {
|
impl RedactedEventContent for RedactedCustomEventContent {
|
||||||
fn empty(event_type: &str) -> Result<Self, serde_json::Error> {
|
fn empty(event_type: &str) -> Result<Self, serde_json::Error> {
|
||||||
Ok(Self { event_type: event_type.to_string() })
|
Ok(Self { event_type: event_type.to_owned() })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_serialize_fields(&self) -> bool {
|
fn has_serialize_fields(&self) -> bool {
|
||||||
|
@ -216,7 +216,7 @@ mod tests {
|
|||||||
transaction_id: "456".into(),
|
transaction_id: "456".into(),
|
||||||
method: AcceptMethod::Custom(CustomContent {
|
method: AcceptMethod::Custom(CustomContent {
|
||||||
method: "m.sas.custom".to_owned(),
|
method: "m.sas.custom".to_owned(),
|
||||||
data: vec![("test".to_string(), JsonValue::from("field"))]
|
data: vec![("test".to_owned(), JsonValue::from("field"))]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.collect::<BTreeMap<String, JsonValue>>(),
|
.collect::<BTreeMap<String, JsonValue>>(),
|
||||||
}),
|
}),
|
||||||
|
@ -331,7 +331,7 @@ mod tests {
|
|||||||
transaction_id: "456".into(),
|
transaction_id: "456".into(),
|
||||||
method: StartMethod::Custom(CustomContent {
|
method: StartMethod::Custom(CustomContent {
|
||||||
method: "m.sas.custom".to_owned(),
|
method: "m.sas.custom".to_owned(),
|
||||||
data: vec![("test".to_string(), JsonValue::from("field"))]
|
data: vec![("test".to_owned(), JsonValue::from("field"))]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.collect::<BTreeMap<String, JsonValue>>(),
|
.collect::<BTreeMap<String, JsonValue>>(),
|
||||||
}),
|
}),
|
||||||
|
@ -20,7 +20,7 @@ struct MessageContentDeHelper {
|
|||||||
new_content: Option<Box<MessageEventContent>>,
|
new_content: Option<Box<MessageEventContent>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de> de::Deserialize<'de> for MessageEventContent {
|
impl<'de> Deserialize<'de> for MessageEventContent {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: de::Deserializer<'de>,
|
D: de::Deserializer<'de>,
|
||||||
@ -44,7 +44,7 @@ struct MessageTypeDeHelper {
|
|||||||
msgtype: String,
|
msgtype: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de> de::Deserialize<'de> for MessageType {
|
impl<'de> Deserialize<'de> for MessageType {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: de::Deserializer<'de>,
|
D: de::Deserializer<'de>,
|
||||||
|
@ -56,10 +56,7 @@ where
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::{
|
use std::time::{Duration, UNIX_EPOCH};
|
||||||
iter::FromIterator,
|
|
||||||
time::{Duration, UNIX_EPOCH},
|
|
||||||
};
|
|
||||||
|
|
||||||
use js_int::int;
|
use js_int::int;
|
||||||
use matches::assert_matches;
|
use matches::assert_matches;
|
||||||
@ -157,7 +154,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn name_fails_validation_when_too_long() {
|
fn name_fails_validation_when_too_long() {
|
||||||
// "XXXX .." 256 times
|
// "XXXX .." 256 times
|
||||||
let long_string: String = String::from_iter(std::iter::repeat('X').take(256));
|
let long_string: String = std::iter::repeat('X').take(256).collect();
|
||||||
assert_eq!(long_string.len(), 256);
|
assert_eq!(long_string.len(), 256);
|
||||||
|
|
||||||
let long_content_json = json!({ "name": &long_string });
|
let long_content_json = json!({ "name": &long_string });
|
||||||
|
@ -63,7 +63,7 @@ mod tests {
|
|||||||
.deserialize()
|
.deserialize()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(server_acl_event.content.allow_ip_literals, true);
|
assert!(server_acl_event.content.allow_ip_literals);
|
||||||
assert!(server_acl_event.content.allow.is_empty());
|
assert!(server_acl_event.content.allow.is_empty());
|
||||||
assert!(server_acl_event.content.deny.is_empty());
|
assert!(server_acl_event.content.deny.is_empty());
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ fn deserialize_ephemeral_receipt() {
|
|||||||
&& room_id == room_id!("!roomid:room.com")
|
&& room_id == room_id!("!roomid:room.com")
|
||||||
&& receipts
|
&& receipts
|
||||||
.get(&event_id)
|
.get(&event_id)
|
||||||
.map(|r| r.read.as_ref().unwrap().get(&user_id).unwrap().clone())
|
.map(|r| r.read.as_ref().unwrap().get(&user_id).unwrap())
|
||||||
.map(|r| r.ts)
|
.map(|r| r.ts)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
== Some(UNIX_EPOCH + Duration::from_millis(1))
|
== Some(UNIX_EPOCH + Duration::from_millis(1))
|
||||||
|
@ -99,7 +99,7 @@ fn redacted_aliases_event_serialize_with_content() {
|
|||||||
let redacted = RedactedSyncStateEvent {
|
let redacted = RedactedSyncStateEvent {
|
||||||
content: RedactedAliasesEventContent { aliases: Some(vec![]) },
|
content: RedactedAliasesEventContent { aliases: Some(vec![]) },
|
||||||
event_id: event_id!("$h29iv0s8:example.com"),
|
event_id: event_id!("$h29iv0s8:example.com"),
|
||||||
state_key: "".to_string(),
|
state_key: "".to_owned(),
|
||||||
origin_server_ts: UNIX_EPOCH + Duration::from_millis(1),
|
origin_server_ts: UNIX_EPOCH + Duration::from_millis(1),
|
||||||
sender: user_id!("@carl:example.com"),
|
sender: user_id!("@carl:example.com"),
|
||||||
unsigned: RedactedSyncUnsigned::default(),
|
unsigned: RedactedSyncUnsigned::default(),
|
||||||
|
@ -301,12 +301,12 @@ fn verification_request_deserialization() {
|
|||||||
fn verification_request_serialization() {
|
fn verification_request_serialization() {
|
||||||
let user_id = user_id!("@example2:localhost");
|
let user_id = user_id!("@example2:localhost");
|
||||||
let device_id: DeviceIdBox = "XOWLHHFSWM".into();
|
let device_id: DeviceIdBox = "XOWLHHFSWM".into();
|
||||||
let body = "@example:localhost is requesting to verify your key, ...".to_string();
|
let body = "@example:localhost is requesting to verify your key, ...".to_owned();
|
||||||
|
|
||||||
let methods = vec![
|
let methods = vec![
|
||||||
VerificationMethod::MSasV1,
|
VerificationMethod::MSasV1,
|
||||||
VerificationMethod::_Custom("m.qr_code.show.v1".to_string()),
|
VerificationMethod::_Custom("m.qr_code.show.v1".to_owned()),
|
||||||
VerificationMethod::_Custom("m.reciprocate.v1".to_string()),
|
VerificationMethod::_Custom("m.reciprocate.v1".to_owned()),
|
||||||
];
|
];
|
||||||
|
|
||||||
let json_data = json!({
|
let json_data = json!({
|
||||||
|
@ -44,7 +44,7 @@ where
|
|||||||
impl<'de> Visitor<'de> for PduProcessResponseVisitor {
|
impl<'de> Visitor<'de> for PduProcessResponseVisitor {
|
||||||
type Value = BTreeMap<EventId, Result<(), String>>;
|
type Value = BTreeMap<EventId, Result<(), String>>;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
formatter.write_str("A map of EventIds to a map of optional errors")
|
formatter.write_str("A map of EventIds to a map of optional errors")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ where
|
|||||||
{
|
{
|
||||||
type Value = T;
|
type Value = T;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
formatter.write_str("a PDU wrapped in an array.")
|
formatter.write_str("a PDU wrapped in an array.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ struct EduDeHelper {
|
|||||||
content: Box<RawJsonValue>,
|
content: Box<RawJsonValue>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de> de::Deserialize<'de> for Edu {
|
impl<'de> Deserialize<'de> for Edu {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: de::Deserializer<'de>,
|
D: de::Deserializer<'de>,
|
||||||
|
@ -12,7 +12,6 @@ edition = "2018"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
ruma-identifiers-validation = { version = "0.3.0", path = "../ruma-identifiers-validation", default-features = false }
|
ruma-identifiers-validation = { version = "0.3.0", path = "../ruma-identifiers-validation", default-features = false }
|
||||||
quote = "1.0.8"
|
quote = "1.0.8"
|
||||||
proc-macro2 = "1.0.24"
|
|
||||||
syn = "1.0.55"
|
syn = "1.0.55"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
@ -16,7 +16,7 @@ struct Input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for Input {
|
impl Parse for Input {
|
||||||
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
|
fn parse(input: syn::parse::ParseStream<'_>) -> syn::Result<Self> {
|
||||||
let dollar_crate = input.parse()?;
|
let dollar_crate = input.parse()?;
|
||||||
let _: Token![,] = input.parse()?;
|
let _: Token![,] = input.parse()?;
|
||||||
let id = input.parse()?;
|
let id = input.parse()?;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use std::{convert::TryInto, fmt, num::NonZeroU8};
|
use std::{convert::TryInto, fmt, num::NonZeroU8};
|
||||||
|
|
||||||
use crate::{crypto_algorithms::DeviceKeyAlgorithm, DeviceId, Error};
|
use crate::{crypto_algorithms::DeviceKeyAlgorithm, DeviceId};
|
||||||
|
|
||||||
/// A key algorithm and a device id, combined with a ':'.
|
/// A key algorithm and a device id, combined with a ':'.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@ -46,7 +46,7 @@ impl DeviceKeyId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_from<S>(key_id: S) -> Result<DeviceKeyId, Error>
|
fn try_from<S>(key_id: S) -> Result<DeviceKeyId, crate::Error>
|
||||||
where
|
where
|
||||||
S: AsRef<str> + Into<Box<str>>,
|
S: AsRef<str> + Into<Box<str>>,
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use std::{convert::TryFrom, fmt, num::NonZeroU8};
|
use std::{convert::TryFrom, fmt, num::NonZeroU8};
|
||||||
|
|
||||||
use crate::{Error, ServerName};
|
use crate::ServerName;
|
||||||
|
|
||||||
/// A Matrix event ID.
|
/// A Matrix event ID.
|
||||||
///
|
///
|
||||||
@ -93,7 +93,7 @@ impl EventId {
|
|||||||
///
|
///
|
||||||
/// If using the original event format as used by Matrix room versions 1 and 2, the string must
|
/// If using the original event format as used by Matrix room versions 1 and 2, the string must
|
||||||
/// include the leading $ sigil, the localpart, a literal colon, and a valid homeserver hostname.
|
/// include the leading $ sigil, the localpart, a literal colon, and a valid homeserver hostname.
|
||||||
fn try_from<S>(event_id: S) -> Result<EventId, Error>
|
fn try_from<S>(event_id: S) -> Result<EventId, crate::Error>
|
||||||
where
|
where
|
||||||
S: AsRef<str> + Into<Box<str>>,
|
S: AsRef<str> + Into<Box<str>>,
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@ use std::{
|
|||||||
str::FromStr,
|
str::FromStr,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{crypto_algorithms::SigningKeyAlgorithm, DeviceId, Error, KeyName};
|
use crate::{crypto_algorithms::SigningKeyAlgorithm, DeviceId, KeyName};
|
||||||
|
|
||||||
/// A key algorithm and key name delimited by a colon
|
/// A key algorithm and key name delimited by a colon
|
||||||
pub struct KeyId<A, K: ?Sized> {
|
pub struct KeyId<A, K: ?Sized> {
|
||||||
@ -57,7 +57,7 @@ impl<A, K: ?Sized> KeyId<A, K> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_from<S, A, K: ?Sized>(key_identifier: S) -> Result<KeyId<A, K>, Error>
|
fn try_from<S, A, K: ?Sized>(key_identifier: S) -> Result<KeyId<A, K>, crate::Error>
|
||||||
where
|
where
|
||||||
S: AsRef<str> + Into<Box<str>>,
|
S: AsRef<str> + Into<Box<str>>,
|
||||||
{
|
{
|
||||||
|
@ -80,7 +80,7 @@ fn generate_localpart(length: usize) -> Box<str> {
|
|||||||
fn deserialize_id<'de, D, T>(deserializer: D, expected_str: &str) -> Result<T, D::Error>
|
fn deserialize_id<'de, D, T>(deserializer: D, expected_str: &str) -> Result<T, D::Error>
|
||||||
where
|
where
|
||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
T: for<'a> std::convert::TryFrom<&'a str>,
|
T: for<'a> TryFrom<&'a str>,
|
||||||
{
|
{
|
||||||
ruma_serde::deserialize_cow_str(deserializer).and_then(|v| {
|
ruma_serde::deserialize_cow_str(deserializer).and_then(|v| {
|
||||||
T::try_from(&v).map_err(|_| de::Error::invalid_value(Unexpected::Str(&v), &expected_str))
|
T::try_from(&v).map_err(|_| de::Error::invalid_value(Unexpected::Str(&v), &expected_str))
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use std::{convert::TryFrom, fmt, num::NonZeroU8};
|
use std::{convert::TryFrom, fmt, num::NonZeroU8};
|
||||||
|
|
||||||
use crate::{server_name::ServerName, Error};
|
use crate::server_name::ServerName;
|
||||||
|
|
||||||
/// A Matrix room alias ID.
|
/// A Matrix room alias ID.
|
||||||
///
|
///
|
||||||
@ -44,7 +44,7 @@ impl RoomAliasId {
|
|||||||
/// Attempts to create a new Matrix room alias ID from a string representation.
|
/// Attempts to create a new Matrix room alias ID from a string representation.
|
||||||
///
|
///
|
||||||
/// The string must include the leading # sigil, the alias, a literal colon, and a server name.
|
/// The string must include the leading # sigil, the alias, a literal colon, and a server name.
|
||||||
fn try_from<S>(room_alias_id: S) -> Result<RoomAliasId, Error>
|
fn try_from<S>(room_alias_id: S) -> Result<RoomAliasId, crate::Error>
|
||||||
where
|
where
|
||||||
S: AsRef<str> + Into<Box<str>>,
|
S: AsRef<str> + Into<Box<str>>,
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use std::{convert::TryFrom, fmt, num::NonZeroU8};
|
use std::{convert::TryFrom, fmt, num::NonZeroU8};
|
||||||
|
|
||||||
use crate::{Error, ServerName};
|
use crate::ServerName;
|
||||||
|
|
||||||
/// A Matrix room ID.
|
/// A Matrix room ID.
|
||||||
///
|
///
|
||||||
@ -60,7 +60,7 @@ impl RoomId {
|
|||||||
/// Attempts to create a new Matrix room ID from a string representation.
|
/// Attempts to create a new Matrix room ID from a string representation.
|
||||||
///
|
///
|
||||||
/// The string must include the leading ! sigil, the localpart, a literal colon, and a server name.
|
/// The string must include the leading ! sigil, the localpart, a literal colon, and a server name.
|
||||||
fn try_from<S>(room_id: S) -> Result<RoomId, Error>
|
fn try_from<S>(room_id: S) -> Result<RoomId, crate::Error>
|
||||||
where
|
where
|
||||||
S: AsRef<str> + Into<Box<str>>,
|
S: AsRef<str> + Into<Box<str>>,
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use std::{convert::TryFrom, fmt, hint::unreachable_unchecked, num::NonZeroU8};
|
use std::{convert::TryFrom, fmt, hint::unreachable_unchecked, num::NonZeroU8};
|
||||||
|
|
||||||
use crate::{server_name::ServerName, Error, RoomAliasId, RoomId};
|
use crate::{server_name::ServerName, RoomAliasId, RoomId};
|
||||||
|
|
||||||
/// A Matrix room ID or a Matrix room alias ID.
|
/// A Matrix room ID or a Matrix room alias ID.
|
||||||
///
|
///
|
||||||
@ -91,7 +91,7 @@ enum Variant {
|
|||||||
/// The string must either include the leading ! sigil, the localpart, a literal colon, and a
|
/// The string must either include the leading ! sigil, the localpart, a literal colon, and a
|
||||||
/// valid homeserver host or include the leading # sigil, the alias, a literal colon, and a
|
/// valid homeserver host or include the leading # sigil, the alias, a literal colon, and a
|
||||||
/// valid homeserver host.
|
/// valid homeserver host.
|
||||||
fn try_from<S>(room_id_or_alias_id: S) -> Result<RoomIdOrAliasId, Error>
|
fn try_from<S>(room_id_or_alias_id: S) -> Result<RoomIdOrAliasId, crate::Error>
|
||||||
where
|
where
|
||||||
S: AsRef<str> + Into<Box<str>>,
|
S: AsRef<str> + Into<Box<str>>,
|
||||||
{
|
{
|
||||||
|
@ -6,8 +6,6 @@ use ruma_serde_macros::DisplayAsRefStr;
|
|||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|
||||||
use crate::Error;
|
|
||||||
|
|
||||||
/// A Matrix room version ID.
|
/// A Matrix room version ID.
|
||||||
///
|
///
|
||||||
/// A `RoomVersionId` can be or converted or deserialized from a string slice, and can be converted
|
/// A `RoomVersionId` can be or converted or deserialized from a string slice, and can be converted
|
||||||
@ -132,7 +130,7 @@ impl<'de> Deserialize<'de> for RoomVersionId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to create a new Matrix room version ID from a string representation.
|
/// Attempts to create a new Matrix room version ID from a string representation.
|
||||||
fn try_from<S>(room_version_id: S) -> Result<RoomVersionId, Error>
|
fn try_from<S>(room_version_id: S) -> Result<RoomVersionId, crate::Error>
|
||||||
where
|
where
|
||||||
S: AsRef<str> + Into<Box<str>>,
|
S: AsRef<str> + Into<Box<str>>,
|
||||||
{
|
{
|
||||||
@ -155,7 +153,7 @@ where
|
|||||||
impl FromStr for RoomVersionId {
|
impl FromStr for RoomVersionId {
|
||||||
type Err = crate::Error;
|
type Err = crate::Error;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Error> {
|
fn from_str(s: &str) -> Result<Self, crate::Error> {
|
||||||
try_from(s)
|
try_from(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -163,7 +161,7 @@ impl FromStr for RoomVersionId {
|
|||||||
impl TryFrom<&str> for RoomVersionId {
|
impl TryFrom<&str> for RoomVersionId {
|
||||||
type Error = crate::Error;
|
type Error = crate::Error;
|
||||||
|
|
||||||
fn try_from(s: &str) -> Result<Self, Error> {
|
fn try_from(s: &str) -> Result<Self, crate::Error> {
|
||||||
try_from(s)
|
try_from(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,7 +169,7 @@ impl TryFrom<&str> for RoomVersionId {
|
|||||||
impl TryFrom<String> for RoomVersionId {
|
impl TryFrom<String> for RoomVersionId {
|
||||||
type Error = crate::Error;
|
type Error = crate::Error;
|
||||||
|
|
||||||
fn try_from(s: String) -> Result<Self, Error> {
|
fn try_from(s: String) -> Result<Self, crate::Error> {
|
||||||
try_from(s)
|
try_from(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@ use std::{convert::TryFrom, fmt, mem, str::FromStr};
|
|||||||
|
|
||||||
use ruma_identifiers_validation::server_name::validate;
|
use ruma_identifiers_validation::server_name::validate;
|
||||||
|
|
||||||
use crate::Error;
|
|
||||||
|
|
||||||
/// A Matrix-spec compliant server name.
|
/// A Matrix-spec compliant server name.
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
@ -66,7 +64,7 @@ impl From<&ServerName> for Box<ServerName> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_from<S>(server_name: S) -> Result<Box<ServerName>, Error>
|
fn try_from<S>(server_name: S) -> Result<Box<ServerName>, crate::Error>
|
||||||
where
|
where
|
||||||
S: AsRef<str> + Into<Box<str>>,
|
S: AsRef<str> + Into<Box<str>>,
|
||||||
{
|
{
|
||||||
@ -93,7 +91,7 @@ impl From<Box<ServerName>> for String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TryFrom<&'a str> for &'a ServerName {
|
impl<'a> TryFrom<&'a str> for &'a ServerName {
|
||||||
type Error = Error;
|
type Error = crate::Error;
|
||||||
|
|
||||||
fn try_from(server_name: &'a str) -> Result<Self, Self::Error> {
|
fn try_from(server_name: &'a str) -> Result<Self, Self::Error> {
|
||||||
validate(server_name)?;
|
validate(server_name)?;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use std::{convert::TryFrom, fmt, num::NonZeroU8};
|
use std::{convert::TryFrom, fmt, num::NonZeroU8};
|
||||||
|
|
||||||
use crate::{Error, ServerName};
|
use crate::ServerName;
|
||||||
|
|
||||||
/// A Matrix user ID.
|
/// A Matrix user ID.
|
||||||
///
|
///
|
||||||
@ -59,7 +59,7 @@ impl UserId {
|
|||||||
pub fn parse_with_server_name(
|
pub fn parse_with_server_name(
|
||||||
id: impl AsRef<str> + Into<Box<str>>,
|
id: impl AsRef<str> + Into<Box<str>>,
|
||||||
server_name: &ServerName,
|
server_name: &ServerName,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, crate::Error> {
|
||||||
let id_str = id.as_ref();
|
let id_str = id.as_ref();
|
||||||
|
|
||||||
if id_str.starts_with('@') {
|
if id_str.starts_with('@') {
|
||||||
@ -98,7 +98,7 @@ impl UserId {
|
|||||||
/// Attempts to create a new Matrix user ID from a string representation.
|
/// Attempts to create a new Matrix user ID from a string representation.
|
||||||
///
|
///
|
||||||
/// The string must include the leading @ sigil, the localpart, a literal colon, and a server name.
|
/// The string must include the leading @ sigil, the localpart, a literal colon, and a server name.
|
||||||
fn try_from<S>(user_id: S) -> Result<UserId, Error>
|
fn try_from<S>(user_id: S) -> Result<UserId, crate::Error>
|
||||||
where
|
where
|
||||||
S: AsRef<str> + Into<Box<str>>,
|
S: AsRef<str> + Into<Box<str>>,
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,8 @@ ruma-common = { version = "0.5.0", path = "../ruma-common" }
|
|||||||
ruma-identifiers = { version = "0.19.0", path = "../ruma-identifiers" }
|
ruma-identifiers = { version = "0.19.0", path = "../ruma-identifiers" }
|
||||||
ruma-serde = { version = "0.3.1", path = "../ruma-serde" }
|
ruma-serde = { version = "0.3.1", path = "../ruma-serde" }
|
||||||
serde = { version = "1.0.118", features = ["derive"] }
|
serde = { version = "1.0.118", features = ["derive"] }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
serde_json = "1.0.61"
|
serde_json = "1.0.61"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -42,7 +42,7 @@ impl<'a> Request<'a> {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
client_secret: &'a str,
|
client_secret: &'a str,
|
||||||
email: &'a str,
|
email: &'a str,
|
||||||
send_attempt: js_int::UInt,
|
send_attempt: UInt,
|
||||||
next_link: Option<&'a str>,
|
next_link: Option<&'a str>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { client_secret, email, send_attempt, next_link }
|
Self { client_secret, email, send_attempt, next_link }
|
||||||
|
@ -48,7 +48,7 @@ impl<'a> Request<'a> {
|
|||||||
client_secret: &'a str,
|
client_secret: &'a str,
|
||||||
country: &'a str,
|
country: &'a str,
|
||||||
phone_number: &'a str,
|
phone_number: &'a str,
|
||||||
send_attempt: js_int::UInt,
|
send_attempt: UInt,
|
||||||
next_link: Option<&'a str>,
|
next_link: Option<&'a str>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { client_secret, country, phone_number, send_attempt, next_link }
|
Self { client_secret, country, phone_number, send_attempt, next_link }
|
||||||
|
@ -227,7 +227,7 @@ mod tweak_serde {
|
|||||||
Deserializer, Serializer,
|
Deserializer, Serializer,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn serialize<S>(tweak: &[super::Tweak], serializer: S) -> Result<S::Ok, S::Error>
|
pub fn serialize<S>(tweak: &[Tweak], serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
{
|
{
|
||||||
@ -249,7 +249,7 @@ mod tweak_serde {
|
|||||||
impl<'de> Visitor<'de> for TweaksVisitor {
|
impl<'de> Visitor<'de> for TweaksVisitor {
|
||||||
type Value = Vec<Tweak>;
|
type Value = Vec<Tweak>;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
formatter.write_str("List of tweaks")
|
formatter.write_str("List of tweaks")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ impl RenameAttr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for RenameAttr {
|
impl Parse for RenameAttr {
|
||||||
fn parse(input: ParseStream) -> syn::Result<Self> {
|
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
|
||||||
let _: kw::rename = input.parse()?;
|
let _: kw::rename = input.parse()?;
|
||||||
let _: Token![=] = input.parse()?;
|
let _: Token![=] = input.parse()?;
|
||||||
Ok(Self(input.parse()?))
|
Ok(Self(input.parse()?))
|
||||||
@ -35,7 +35,7 @@ impl RenameAllAttr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for RenameAllAttr {
|
impl Parse for RenameAllAttr {
|
||||||
fn parse(input: ParseStream) -> syn::Result<Self> {
|
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
|
||||||
let _: kw::rename_all = input.parse()?;
|
let _: kw::rename_all = input.parse()?;
|
||||||
let _: Token![=] = input.parse()?;
|
let _: Token![=] = input.parse()?;
|
||||||
let s: LitStr = input.parse()?;
|
let s: LitStr = input.parse()?;
|
||||||
|
@ -6,7 +6,7 @@ use crate::util::{get_rename, get_rename_rule};
|
|||||||
|
|
||||||
pub fn expand_enum_as_ref_str(input: &ItemEnum) -> syn::Result<TokenStream> {
|
pub fn expand_enum_as_ref_str(input: &ItemEnum) -> syn::Result<TokenStream> {
|
||||||
let enum_name = &input.ident;
|
let enum_name = &input.ident;
|
||||||
let rename_rule = get_rename_rule(&input)?;
|
let rename_rule = get_rename_rule(input)?;
|
||||||
let branches: Vec<_> = input
|
let branches: Vec<_> = input
|
||||||
.variants
|
.variants
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -6,7 +6,7 @@ use crate::util::{get_rename, get_rename_rule};
|
|||||||
|
|
||||||
pub fn expand_enum_from_string(input: &ItemEnum) -> syn::Result<TokenStream> {
|
pub fn expand_enum_from_string(input: &ItemEnum) -> syn::Result<TokenStream> {
|
||||||
let enum_name = &input.ident;
|
let enum_name = &input.ident;
|
||||||
let rename_rule = get_rename_rule(&input)?;
|
let rename_rule = get_rename_rule(input)?;
|
||||||
let mut fallback = None;
|
let mut fallback = None;
|
||||||
let mut fallback_ty = None;
|
let mut fallback_ty = None;
|
||||||
let branches: Vec<_> = input
|
let branches: Vec<_> = input
|
||||||
|
@ -173,7 +173,7 @@ fn impl_outgoing_with_incoming_self(input: &DeriveInput, ruma_serde: &TokenStrea
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn split_for_impl_lifetime_less(generics: &mut Generics) -> (ImplGenerics, TypeGenerics) {
|
fn split_for_impl_lifetime_less(generics: &mut Generics) -> (ImplGenerics<'_>, TypeGenerics<'_>) {
|
||||||
generics.params = generics
|
generics.params = generics
|
||||||
.params
|
.params
|
||||||
.clone()
|
.clone()
|
||||||
@ -307,7 +307,7 @@ pub struct Meta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for Meta {
|
impl Parse for Meta {
|
||||||
fn parse(input: ParseStream) -> syn::Result<Self> {
|
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
derive_macs: Punctuated::<_, Token![,]>::parse_terminated(input)?.into_iter().collect(),
|
derive_macs: Punctuated::<_, Token![,]>::parse_terminated(input)?.into_iter().collect(),
|
||||||
})
|
})
|
||||||
@ -320,7 +320,7 @@ pub enum DeriveMac {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for DeriveMac {
|
impl Parse for DeriveMac {
|
||||||
fn parse(input: ParseStream) -> syn::Result<Self> {
|
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
|
||||||
if input.peek(Token![!]) {
|
if input.peek(Token![!]) {
|
||||||
let _: Token![!] = input.parse()?;
|
let _: Token![!] = input.parse()?;
|
||||||
let mac: Ident = input.parse()?;
|
let mac: Ident = input.parse()?;
|
||||||
|
@ -36,7 +36,7 @@ pub enum Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Error {
|
impl fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Error::IntConvert => f.write_str("number found is not a valid `js_int::Int`"),
|
Error::IntConvert => f.write_str("number found is not a valid `js_int::Int`"),
|
||||||
Error::JsonSize => f.write_str("JSON is larger than 65,535 byte max"),
|
Error::JsonSize => f.write_str("JSON is larger than 65,535 byte max"),
|
||||||
|
@ -128,7 +128,7 @@ impl Default for CanonicalJsonValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for CanonicalJsonValue {
|
impl fmt::Debug for CanonicalJsonValue {
|
||||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
Self::Null => formatter.debug_tuple("Null").finish(),
|
Self::Null => formatter.debug_tuple("Null").finish(),
|
||||||
Self::Bool(v) => formatter.debug_tuple("Bool").field(&v).finish(),
|
Self::Bool(v) => formatter.debug_tuple("Bool").field(&v).finish(),
|
||||||
@ -157,7 +157,7 @@ impl fmt::Display for CanonicalJsonValue {
|
|||||||
///
|
///
|
||||||
/// If you want to pretty-print a `CanonicalJsonValue` for debugging purposes, use
|
/// If you want to pretty-print a `CanonicalJsonValue` for debugging purposes, use
|
||||||
/// one of `serde_json::{to_string_pretty, to_vec_pretty, to_writer_pretty}`.
|
/// one of `serde_json::{to_string_pretty, to_vec_pretty, to_writer_pretty}`.
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{}", to_json_string(&self).map_err(|_| fmt::Error)?)
|
write!(f, "{}", to_json_string(&self).map_err(|_| fmt::Error)?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ struct CowStrVisitor;
|
|||||||
impl<'de> Visitor<'de> for CowStrVisitor {
|
impl<'de> Visitor<'de> for CowStrVisitor {
|
||||||
type Value = Cow<'de, str>;
|
type Value = Cow<'de, str>;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
formatter.write_str("a string")
|
formatter.write_str("a string")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ impl<T> Raw<T> {
|
|||||||
{
|
{
|
||||||
type Value = Option<T>;
|
type Value = Option<T>;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn expecting(&self, formatter: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
formatter.write_str("a string")
|
formatter.write_str("a string")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ impl<T> Raw<T> {
|
|||||||
A: MapAccess<'de>,
|
A: MapAccess<'de>,
|
||||||
{
|
{
|
||||||
let mut res = None;
|
let mut res = None;
|
||||||
while let Some(key) = map.next_key::<MyCowStr>()? {
|
while let Some(key) = map.next_key::<MyCowStr<'_>>()? {
|
||||||
if key.get() == self.field_name {
|
if key.get() == self.field_name {
|
||||||
res = Some(map.next_value()?);
|
res = Some(map.next_value()?);
|
||||||
} else {
|
} else {
|
||||||
|
@ -62,7 +62,7 @@ where
|
|||||||
impl<'de> Visitor<'de> for IntOrStringVisitor {
|
impl<'de> Visitor<'de> for IntOrStringVisitor {
|
||||||
type Value = Int;
|
type Value = Int;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
formatter.write_str("an integer or a string")
|
formatter.write_str("an integer or a string")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ where
|
|||||||
{
|
{
|
||||||
type Value = BTreeMap<T, Int>;
|
type Value = BTreeMap<T, Int>;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
formatter.write_str("a map with integers or stings as values")
|
formatter.write_str("a map with integers or stings as values")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,11 +39,11 @@ pub fn to_string<T: ser::Serialize>(input: T) -> Result<String, Error> {
|
|||||||
/// unit variants.
|
/// unit variants.
|
||||||
///
|
///
|
||||||
/// * Newtype structs defer to their inner values.
|
/// * Newtype structs defer to their inner values.
|
||||||
pub struct Serializer<'input, 'output, Target: 'output + UrlEncodedTarget> {
|
pub struct Serializer<'input, 'output, Target: UrlEncodedTarget> {
|
||||||
urlencoder: &'output mut UrlEncodedSerializer<'input, Target>,
|
urlencoder: &'output mut UrlEncodedSerializer<'input, Target>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'input, 'output, Target: 'output + UrlEncodedTarget> Serializer<'input, 'output, Target> {
|
impl<'input, 'output, Target: UrlEncodedTarget> Serializer<'input, 'output, Target> {
|
||||||
/// Returns a new `Serializer`.
|
/// Returns a new `Serializer`.
|
||||||
pub fn new(urlencoder: &'output mut UrlEncodedSerializer<'input, Target>) -> Self {
|
pub fn new(urlencoder: &'output mut UrlEncodedSerializer<'input, Target>) -> Self {
|
||||||
Serializer { urlencoder }
|
Serializer { urlencoder }
|
||||||
@ -60,7 +60,7 @@ pub enum Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Error {
|
impl fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
Error::Custom(ref msg) => msg.fmt(f),
|
Error::Custom(ref msg) => msg.fmt(f),
|
||||||
Error::Utf8(ref err) => write!(f, "invalid UTF-8: {}", err),
|
Error::Utf8(ref err) => write!(f, "invalid UTF-8: {}", err),
|
||||||
@ -93,52 +93,52 @@ impl ser::Error for Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Sequence serializer.
|
/// Sequence serializer.
|
||||||
pub struct SeqSerializer<'input, 'output, Target: 'output + UrlEncodedTarget> {
|
pub struct SeqSerializer<'input, 'output, Target: UrlEncodedTarget> {
|
||||||
urlencoder: &'output mut UrlEncodedSerializer<'input, Target>,
|
urlencoder: &'output mut UrlEncodedSerializer<'input, Target>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tuple serializer.
|
/// Tuple serializer.
|
||||||
///
|
///
|
||||||
/// Mostly used for arrays.
|
/// Mostly used for arrays.
|
||||||
pub struct TupleSerializer<'input, 'output, Target: 'output + UrlEncodedTarget> {
|
pub struct TupleSerializer<'input, 'output, Target: UrlEncodedTarget> {
|
||||||
urlencoder: &'output mut UrlEncodedSerializer<'input, Target>,
|
urlencoder: &'output mut UrlEncodedSerializer<'input, Target>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tuple struct serializer.
|
/// Tuple struct serializer.
|
||||||
///
|
///
|
||||||
/// Never instantiated, tuple structs are not supported.
|
/// Never instantiated, tuple structs are not supported.
|
||||||
pub struct TupleStructSerializer<'input, 'output, T: 'output + UrlEncodedTarget> {
|
pub struct TupleStructSerializer<'input, 'output, T: UrlEncodedTarget> {
|
||||||
inner: ser::Impossible<&'output mut UrlEncodedSerializer<'input, T>, Error>,
|
inner: ser::Impossible<&'output mut UrlEncodedSerializer<'input, T>, Error>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tuple variant serializer.
|
/// Tuple variant serializer.
|
||||||
///
|
///
|
||||||
/// Never instantiated, tuple variants are not supported.
|
/// Never instantiated, tuple variants are not supported.
|
||||||
pub struct TupleVariantSerializer<'input, 'output, T: 'output + UrlEncodedTarget> {
|
pub struct TupleVariantSerializer<'input, 'output, T: UrlEncodedTarget> {
|
||||||
inner: ser::Impossible<&'output mut UrlEncodedSerializer<'input, T>, Error>,
|
inner: ser::Impossible<&'output mut UrlEncodedSerializer<'input, T>, Error>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Map serializer.
|
/// Map serializer.
|
||||||
pub struct MapSerializer<'input, 'output, Target: 'output + UrlEncodedTarget> {
|
pub struct MapSerializer<'input, 'output, Target: UrlEncodedTarget> {
|
||||||
urlencoder: &'output mut UrlEncodedSerializer<'input, Target>,
|
urlencoder: &'output mut UrlEncodedSerializer<'input, Target>,
|
||||||
key: Option<Cow<'static, str>>,
|
key: Option<Cow<'static, str>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Struct serializer.
|
/// Struct serializer.
|
||||||
pub struct StructSerializer<'input, 'output, Target: 'output + UrlEncodedTarget> {
|
pub struct StructSerializer<'input, 'output, Target: UrlEncodedTarget> {
|
||||||
urlencoder: &'output mut UrlEncodedSerializer<'input, Target>,
|
urlencoder: &'output mut UrlEncodedSerializer<'input, Target>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Struct variant serializer.
|
/// Struct variant serializer.
|
||||||
///
|
///
|
||||||
/// Never instantiated, struct variants are not supported.
|
/// Never instantiated, struct variants are not supported.
|
||||||
pub struct StructVariantSerializer<'input, 'output, T: 'output + UrlEncodedTarget> {
|
pub struct StructVariantSerializer<'input, 'output, T: UrlEncodedTarget> {
|
||||||
inner: ser::Impossible<&'output mut UrlEncodedSerializer<'input, T>, Error>,
|
inner: ser::Impossible<&'output mut UrlEncodedSerializer<'input, T>, Error>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'input, 'output, Target> ser::Serializer for Serializer<'input, 'output, Target>
|
impl<'input, 'output, Target> ser::Serializer for Serializer<'input, 'output, Target>
|
||||||
where
|
where
|
||||||
Target: 'output + UrlEncodedTarget,
|
Target: UrlEncodedTarget,
|
||||||
{
|
{
|
||||||
type Ok = &'output mut UrlEncodedSerializer<'input, Target>;
|
type Ok = &'output mut UrlEncodedSerializer<'input, Target>;
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
@ -328,7 +328,7 @@ where
|
|||||||
|
|
||||||
impl<'input, 'output, Target> ser::SerializeSeq for SeqSerializer<'input, 'output, Target>
|
impl<'input, 'output, Target> ser::SerializeSeq for SeqSerializer<'input, 'output, Target>
|
||||||
where
|
where
|
||||||
Target: 'output + UrlEncodedTarget,
|
Target: UrlEncodedTarget,
|
||||||
{
|
{
|
||||||
type Ok = &'output mut UrlEncodedSerializer<'input, Target>;
|
type Ok = &'output mut UrlEncodedSerializer<'input, Target>;
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
@ -344,7 +344,7 @@ where
|
|||||||
|
|
||||||
impl<'input, 'output, Target> ser::SerializeTuple for TupleSerializer<'input, 'output, Target>
|
impl<'input, 'output, Target> ser::SerializeTuple for TupleSerializer<'input, 'output, Target>
|
||||||
where
|
where
|
||||||
Target: 'output + UrlEncodedTarget,
|
Target: UrlEncodedTarget,
|
||||||
{
|
{
|
||||||
type Ok = &'output mut UrlEncodedSerializer<'input, Target>;
|
type Ok = &'output mut UrlEncodedSerializer<'input, Target>;
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
@ -361,7 +361,7 @@ where
|
|||||||
impl<'input, 'output, Target> ser::SerializeTupleStruct
|
impl<'input, 'output, Target> ser::SerializeTupleStruct
|
||||||
for TupleStructSerializer<'input, 'output, Target>
|
for TupleStructSerializer<'input, 'output, Target>
|
||||||
where
|
where
|
||||||
Target: 'output + UrlEncodedTarget,
|
Target: UrlEncodedTarget,
|
||||||
{
|
{
|
||||||
type Ok = &'output mut UrlEncodedSerializer<'input, Target>;
|
type Ok = &'output mut UrlEncodedSerializer<'input, Target>;
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
@ -378,7 +378,7 @@ where
|
|||||||
impl<'input, 'output, Target> ser::SerializeTupleVariant
|
impl<'input, 'output, Target> ser::SerializeTupleVariant
|
||||||
for TupleVariantSerializer<'input, 'output, Target>
|
for TupleVariantSerializer<'input, 'output, Target>
|
||||||
where
|
where
|
||||||
Target: 'output + UrlEncodedTarget,
|
Target: UrlEncodedTarget,
|
||||||
{
|
{
|
||||||
type Ok = &'output mut UrlEncodedSerializer<'input, Target>;
|
type Ok = &'output mut UrlEncodedSerializer<'input, Target>;
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
@ -394,7 +394,7 @@ where
|
|||||||
|
|
||||||
impl<'input, 'output, Target> ser::SerializeMap for MapSerializer<'input, 'output, Target>
|
impl<'input, 'output, Target> ser::SerializeMap for MapSerializer<'input, 'output, Target>
|
||||||
where
|
where
|
||||||
Target: 'output + UrlEncodedTarget,
|
Target: UrlEncodedTarget,
|
||||||
{
|
{
|
||||||
type Ok = &'output mut UrlEncodedSerializer<'input, Target>;
|
type Ok = &'output mut UrlEncodedSerializer<'input, Target>;
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
@ -424,7 +424,7 @@ where
|
|||||||
fn serialize_value<T: ?Sized + ser::Serialize>(&mut self, value: &T) -> Result<(), Error> {
|
fn serialize_value<T: ?Sized + ser::Serialize>(&mut self, value: &T) -> Result<(), Error> {
|
||||||
{
|
{
|
||||||
let key = self.key.as_ref().ok_or_else(Error::no_key)?;
|
let key = self.key.as_ref().ok_or_else(Error::no_key)?;
|
||||||
let value_sink = value::ValueSink::new(self.urlencoder, &key);
|
let value_sink = value::ValueSink::new(self.urlencoder, key);
|
||||||
value.serialize(part::PartSerializer::new(value_sink))?;
|
value.serialize(part::PartSerializer::new(value_sink))?;
|
||||||
}
|
}
|
||||||
self.key = None;
|
self.key = None;
|
||||||
@ -438,7 +438,7 @@ where
|
|||||||
|
|
||||||
impl<'input, 'output, Target> ser::SerializeStruct for StructSerializer<'input, 'output, Target>
|
impl<'input, 'output, Target> ser::SerializeStruct for StructSerializer<'input, 'output, Target>
|
||||||
where
|
where
|
||||||
Target: 'output + UrlEncodedTarget,
|
Target: UrlEncodedTarget,
|
||||||
{
|
{
|
||||||
type Ok = &'output mut UrlEncodedSerializer<'input, Target>;
|
type Ok = &'output mut UrlEncodedSerializer<'input, Target>;
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
@ -460,7 +460,7 @@ where
|
|||||||
impl<'input, 'output, Target> ser::SerializeStructVariant
|
impl<'input, 'output, Target> ser::SerializeStructVariant
|
||||||
for StructVariantSerializer<'input, 'output, Target>
|
for StructVariantSerializer<'input, 'output, Target>
|
||||||
where
|
where
|
||||||
Target: 'output + UrlEncodedTarget,
|
Target: UrlEncodedTarget,
|
||||||
{
|
{
|
||||||
type Ok = &'output mut UrlEncodedSerializer<'input, Target>;
|
type Ok = &'output mut UrlEncodedSerializer<'input, Target>;
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
@ -5,7 +5,7 @@ use serde::ser;
|
|||||||
|
|
||||||
use super::{key::KeySink, part::PartSerializer, value::ValueSink, Error};
|
use super::{key::KeySink, part::PartSerializer, value::ValueSink, Error};
|
||||||
|
|
||||||
pub struct PairSerializer<'input, 'target, Target: 'target + UrlEncodedTarget> {
|
pub struct PairSerializer<'input, 'target, Target: UrlEncodedTarget> {
|
||||||
urlencoder: &'target mut UrlEncodedSerializer<'input, Target>,
|
urlencoder: &'target mut UrlEncodedSerializer<'input, Target>,
|
||||||
state: PairState,
|
state: PairState,
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ use super::{
|
|||||||
|
|
||||||
pub struct ValueSink<'input, 'key, 'target, Target>
|
pub struct ValueSink<'input, 'key, 'target, Target>
|
||||||
where
|
where
|
||||||
Target: 'target + UrlEncodedTarget,
|
Target: UrlEncodedTarget,
|
||||||
{
|
{
|
||||||
urlencoder: &'target mut UrlEncodedSerializer<'input, Target>,
|
urlencoder: &'target mut UrlEncodedSerializer<'input, Target>,
|
||||||
key: &'key str,
|
key: &'key str,
|
||||||
|
@ -155,7 +155,7 @@ where
|
|||||||
|
|
||||||
// Insert the new signature in the map we pulled out (or created) previously.
|
// Insert the new signature in the map we pulled out (or created) previously.
|
||||||
let signature_set = signature_map
|
let signature_set = signature_map
|
||||||
.entry(entity_id.to_string())
|
.entry(entity_id.to_owned())
|
||||||
.or_insert_with(|| CanonicalJsonValue::Object(BTreeMap::new()));
|
.or_insert_with(|| CanonicalJsonValue::Object(BTreeMap::new()));
|
||||||
|
|
||||||
let signature_set = match signature_set {
|
let signature_set = match signature_set {
|
||||||
@ -235,7 +235,7 @@ pub fn canonical_json(object: &CanonicalJsonObject) -> String {
|
|||||||
///
|
///
|
||||||
/// // Create the `PublicKeyMap` that will inform `verify_json` which signatures to verify.
|
/// // Create the `PublicKeyMap` that will inform `verify_json` which signatures to verify.
|
||||||
/// let mut public_key_set = BTreeMap::new();
|
/// let mut public_key_set = BTreeMap::new();
|
||||||
/// public_key_set.insert("ed25519:1".into(), PUBLIC_KEY.to_string());
|
/// public_key_set.insert("ed25519:1".into(), PUBLIC_KEY.to_owned());
|
||||||
/// let mut public_key_map = BTreeMap::new();
|
/// let mut public_key_map = BTreeMap::new();
|
||||||
/// public_key_map.insert("domain".into(), public_key_set);
|
/// public_key_map.insert("domain".into(), public_key_set);
|
||||||
///
|
///
|
||||||
@ -550,7 +550,7 @@ where
|
|||||||
///
|
///
|
||||||
/// // Create the `PublicKeyMap` that will inform `verify_json` which signatures to verify.
|
/// // Create the `PublicKeyMap` that will inform `verify_json` which signatures to verify.
|
||||||
/// let mut public_key_set = BTreeMap::new();
|
/// let mut public_key_set = BTreeMap::new();
|
||||||
/// public_key_set.insert("ed25519:1".into(), PUBLIC_KEY.to_string());
|
/// public_key_set.insert("ed25519:1".into(), PUBLIC_KEY.to_owned());
|
||||||
/// let mut public_key_map = BTreeMap::new();
|
/// let mut public_key_map = BTreeMap::new();
|
||||||
/// public_key_map.insert("domain".into(), public_key_set);
|
/// public_key_map.insert("domain".into(), public_key_set);
|
||||||
///
|
///
|
||||||
@ -976,7 +976,7 @@ mod tests {
|
|||||||
key_pair_sender.version().try_into().unwrap(),
|
key_pair_sender.version().try_into().unwrap(),
|
||||||
);
|
);
|
||||||
sender_key_map.insert(version.to_string(), encoded_public_key);
|
sender_key_map.insert(version.to_string(), encoded_public_key);
|
||||||
public_key_map.insert("domain-sender".to_string(), sender_key_map);
|
public_key_map.insert("domain-sender".to_owned(), sender_key_map);
|
||||||
|
|
||||||
let verification_result =
|
let verification_result =
|
||||||
verify_event(&public_key_map, &signed_event, &RoomVersionId::Version6);
|
verify_event(&public_key_map, &signed_event, &RoomVersionId::Version6);
|
||||||
@ -988,7 +988,7 @@ mod tests {
|
|||||||
|
|
||||||
fn generate_key_pair() -> Ed25519KeyPair {
|
fn generate_key_pair() -> Ed25519KeyPair {
|
||||||
let key_content = Ed25519KeyPair::generate().unwrap();
|
let key_content = Ed25519KeyPair::generate().unwrap();
|
||||||
Ed25519KeyPair::new(&key_content, "1".to_string()).unwrap()
|
Ed25519KeyPair::new(&key_content, "1".to_owned()).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_key_to_map(public_key_map: &mut PublicKeyMap, name: &str, pair: &Ed25519KeyPair) {
|
fn add_key_to_map(public_key_map: &mut PublicKeyMap, name: &str, pair: &Ed25519KeyPair) {
|
||||||
@ -1001,6 +1001,6 @@ mod tests {
|
|||||||
|
|
||||||
sender_key_map.insert(version.to_string(), encoded_public_key);
|
sender_key_map.insert(version.to_string(), encoded_public_key);
|
||||||
|
|
||||||
public_key_map.insert(name.to_string(), sender_key_map);
|
public_key_map.insert(name.to_owned(), sender_key_map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,8 +110,8 @@ impl From<serde_json::Error> for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ruma_serde::CanonicalJsonError> for Error {
|
impl From<CanonicalJsonError> for Error {
|
||||||
fn from(error: ruma_serde::CanonicalJsonError) -> Self {
|
fn from(error: CanonicalJsonError) -> Self {
|
||||||
Self::new(error.to_string())
|
Self::new(error.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -163,7 +163,7 @@ fn split_id(id: &str) -> Result<(Algorithm, String), SplitError<'_>> {
|
|||||||
algorithm => return Err(SplitError::UnknownAlgorithm(algorithm)),
|
algorithm => return Err(SplitError::UnknownAlgorithm(algorithm)),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok((algorithm, signature_id[1].to_string()))
|
Ok((algorithm, signature_id[1].to_owned()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -416,9 +416,6 @@ impl VersionExt for Version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
next.pre = vec![];
|
next.pre = vec![];
|
||||||
if next == *version {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
next.increment_patch();
|
next.increment_patch();
|
||||||
if next == *version {
|
if next == *version {
|
||||||
@ -446,11 +443,7 @@ impl VersionExt for Version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
next.add_pre_release();
|
next.add_pre_release();
|
||||||
if next == *version {
|
}
|
||||||
return true;
|
next == *version
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user