serde: Rename derive macro Outgoing to Incoming
All it does now is generate `Incoming{Self}` types.
This commit is contained in:
parent
5cf42f3a86
commit
a6a530dcc8
@ -19,13 +19,13 @@ pub mod request_registration_token_via_msisdn;
|
||||
pub mod unbind_3pid;
|
||||
pub mod whoami;
|
||||
|
||||
use ruma_common::serde::{Outgoing, StringEnum};
|
||||
use ruma_common::serde::{Incoming, StringEnum};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::PrivOwnedStr;
|
||||
|
||||
/// Additional authentication information for requestToken endpoints.
|
||||
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
pub struct IdentityServerInfo<'a> {
|
||||
/// The ID server to send the onward request to as a hostname with an
|
||||
|
@ -8,7 +8,7 @@ mod url;
|
||||
|
||||
use js_int::UInt;
|
||||
use ruma_common::{
|
||||
serde::{Outgoing, StringEnum},
|
||||
serde::{Incoming, StringEnum},
|
||||
RoomId, UserId,
|
||||
};
|
||||
use serde::Serialize;
|
||||
@ -83,7 +83,7 @@ impl RelationType {
|
||||
}
|
||||
|
||||
/// Filters to be applied to room events.
|
||||
#[derive(Clone, Debug, Default, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Default, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[incoming_derive(Clone, Default, Serialize)]
|
||||
pub struct RoomEventFilter<'a> {
|
||||
@ -228,7 +228,7 @@ impl IncomingRoomEventFilter {
|
||||
}
|
||||
|
||||
/// Filters to be applied to room data.
|
||||
#[derive(Clone, Debug, Default, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Default, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[incoming_derive(Clone, Default, Serialize)]
|
||||
pub struct RoomFilter<'a> {
|
||||
@ -310,7 +310,7 @@ impl IncomingRoomFilter {
|
||||
}
|
||||
|
||||
/// Filter for non-room data.
|
||||
#[derive(Clone, Debug, Default, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Default, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[incoming_derive(Clone, Default, Serialize)]
|
||||
pub struct Filter<'a> {
|
||||
@ -382,7 +382,7 @@ impl IncomingFilter {
|
||||
}
|
||||
|
||||
/// A filter definition
|
||||
#[derive(Clone, Debug, Default, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Default, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[incoming_derive(Clone, Default, Serialize)]
|
||||
pub struct FilterDefinition<'a> {
|
||||
|
@ -14,12 +14,12 @@ pub mod unban_user;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use ruma_common::{serde::Outgoing, thirdparty::Medium, ServerName, ServerSigningKeyId, UserId};
|
||||
use ruma_common::{serde::Incoming, thirdparty::Medium, ServerName, ServerSigningKeyId, UserId};
|
||||
use serde::Serialize;
|
||||
|
||||
/// A signature of an `m.third_party_invite` token to prove that this user owns a third party
|
||||
/// identity which has been invited to the room.
|
||||
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
pub struct ThirdPartySigned<'a> {
|
||||
/// The Matrix ID of the user who issued the invite.
|
||||
@ -52,7 +52,7 @@ impl<'a> ThirdPartySigned<'a> {
|
||||
///
|
||||
/// To create an instance of this type, first create a `Invite3pidInit` and convert it via
|
||||
/// `Invite3pid::from` / `.into()`.
|
||||
#[derive(Clone, Debug, PartialEq, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[incoming_derive(PartialEq)]
|
||||
pub struct Invite3pid<'a> {
|
||||
|
@ -10,7 +10,7 @@ pub mod v3 {
|
||||
//! [spec-mxid]: https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3roomsroomidinvite
|
||||
//! [spec-3pid]: https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3roomsroomidinvite-1
|
||||
|
||||
use ruma_common::{api::ruma_api, serde::Outgoing, RoomId, UserId};
|
||||
use ruma_common::{api::ruma_api, serde::Incoming, RoomId, UserId};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::membership::{IncomingInvite3pid, Invite3pid};
|
||||
@ -62,7 +62,7 @@ pub mod v3 {
|
||||
}
|
||||
|
||||
/// Distinguishes between invititations by Matrix or third party identifiers.
|
||||
#[derive(Clone, Debug, PartialEq, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[incoming_derive(PartialEq)]
|
||||
#[serde(untagged)]
|
||||
|
@ -11,7 +11,7 @@ pub mod v3 {
|
||||
use ruma_common::{
|
||||
api::ruma_api,
|
||||
events::{AnyRoomEvent, AnyStateEvent},
|
||||
serde::{Outgoing, Raw, StringEnum},
|
||||
serde::{Incoming, Raw, StringEnum},
|
||||
EventId, MxcUri, RoomId, UserId,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -67,7 +67,7 @@ pub mod v3 {
|
||||
}
|
||||
|
||||
/// Categories of events that can be searched for.
|
||||
#[derive(Clone, Debug, Default, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Default, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
pub struct Categories<'a> {
|
||||
/// Criteria for searching room events.
|
||||
@ -83,7 +83,7 @@ pub mod v3 {
|
||||
}
|
||||
|
||||
/// Criteria for searching a category of events.
|
||||
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
pub struct Criteria<'a> {
|
||||
/// The string to search events for.
|
||||
@ -275,7 +275,7 @@ pub mod v3 {
|
||||
}
|
||||
|
||||
/// Requests that the server partitions the result set based on the provided list of keys.
|
||||
#[derive(Clone, Default, Debug, Outgoing, Serialize)]
|
||||
#[derive(Clone, Default, Debug, Incoming, Serialize)]
|
||||
#[incoming_derive(Default)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
pub struct Groupings<'a> {
|
||||
|
@ -7,7 +7,7 @@ pub mod v3 {
|
||||
|
||||
use ruma_common::{
|
||||
api::ruma_api,
|
||||
serde::{JsonObject, Outgoing},
|
||||
serde::{Incoming, JsonObject},
|
||||
DeviceId, ServerName, UserId,
|
||||
};
|
||||
use serde::{
|
||||
@ -94,7 +94,7 @@ pub mod v3 {
|
||||
///
|
||||
/// To construct the custom `LoginInfo` variant you first have to construct
|
||||
/// [`IncomingLoginInfo::new`] and then call [`IncomingLoginInfo::to_outgoing`] on it.
|
||||
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[incoming_derive(!Deserialize)]
|
||||
#[serde(untagged)]
|
||||
@ -177,7 +177,7 @@ pub mod v3 {
|
||||
}
|
||||
|
||||
/// An identifier and password to supply as authentication.
|
||||
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[serde(tag = "type", rename = "m.login.password")]
|
||||
pub struct Password<'a> {
|
||||
@ -203,7 +203,7 @@ pub mod v3 {
|
||||
}
|
||||
|
||||
/// A token to supply as authentication.
|
||||
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[serde(tag = "type", rename = "m.login.token")]
|
||||
pub struct Token<'a> {
|
||||
@ -226,7 +226,7 @@ pub mod v3 {
|
||||
}
|
||||
|
||||
/// An identifier to supply for Application Service authentication.
|
||||
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[serde(tag = "type", rename = "m.login.application_service")]
|
||||
pub struct ApplicationService<'a> {
|
||||
|
@ -8,7 +8,7 @@ pub mod v3 {
|
||||
use ruma_common::{
|
||||
api::ruma_api,
|
||||
events::{AnyStateEventContent, StateEventType},
|
||||
serde::{Outgoing, Raw},
|
||||
serde::{Incoming, Raw},
|
||||
RoomId,
|
||||
};
|
||||
|
||||
@ -39,7 +39,7 @@ pub mod v3 {
|
||||
/// Data for a request to the `get_state_events_for_key` API endpoint.
|
||||
///
|
||||
/// Get state events associated with a given key.
|
||||
#[derive(Clone, Debug, Outgoing)]
|
||||
#[derive(Clone, Debug, Incoming)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[incoming_derive(!Deserialize)]
|
||||
pub struct Request<'a> {
|
||||
|
@ -8,7 +8,7 @@ pub mod v3 {
|
||||
use ruma_common::{
|
||||
api::ruma_api,
|
||||
events::{AnyStateEventContent, EventContent, StateEventType},
|
||||
serde::{Outgoing, Raw},
|
||||
serde::{Incoming, Raw},
|
||||
EventId, RoomId,
|
||||
};
|
||||
use serde_json::value::to_raw_value as to_raw_json_value;
|
||||
@ -36,7 +36,7 @@ pub mod v3 {
|
||||
/// Data for a request to the `send_state_event` API endpoint.
|
||||
///
|
||||
/// Send a state event to a room associated with a given state key.
|
||||
#[derive(Clone, Debug, Outgoing)]
|
||||
#[derive(Clone, Debug, Incoming)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[incoming_derive(!Deserialize)]
|
||||
pub struct Request<'a> {
|
||||
|
@ -16,7 +16,7 @@ pub mod v3 {
|
||||
AnyToDeviceEvent,
|
||||
},
|
||||
presence::PresenceState,
|
||||
serde::{Outgoing, Raw},
|
||||
serde::{Incoming, Raw},
|
||||
DeviceKeyAlgorithm, RoomId, UserId,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -138,7 +138,7 @@ pub mod v3 {
|
||||
}
|
||||
|
||||
/// A filter represented either as its full JSON definition or the ID of a saved filter.
|
||||
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[serde(untagged)]
|
||||
|
@ -10,7 +10,7 @@ use ruma_common::{
|
||||
error::{DeserializationError, IntoHttpError},
|
||||
EndpointError, OutgoingResponse,
|
||||
},
|
||||
serde::{from_raw_json_value, JsonObject, Outgoing, StringEnum},
|
||||
serde::{from_raw_json_value, Incoming, JsonObject, StringEnum},
|
||||
thirdparty::Medium,
|
||||
ClientSecret, SessionId,
|
||||
};
|
||||
@ -34,7 +34,7 @@ mod user_serde;
|
||||
///
|
||||
/// To construct the custom `AuthData` variant you first have to construct [`IncomingAuthData::new`]
|
||||
/// and then call [`IncomingAuthData::to_outgoing`] on it.
|
||||
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
||||
#[non_exhaustive]
|
||||
#[incoming_derive(!Deserialize)]
|
||||
#[serde(untagged)]
|
||||
@ -342,7 +342,7 @@ pub enum AuthType {
|
||||
/// See [the spec] for how to use this.
|
||||
///
|
||||
/// [the spec]: https://spec.matrix.org/v1.2/client-server-api/#password-based
|
||||
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[serde(tag = "type", rename = "m.login.password")]
|
||||
pub struct Password<'a> {
|
||||
@ -379,7 +379,7 @@ impl IncomingPassword {
|
||||
/// See [the spec] for how to use this.
|
||||
///
|
||||
/// [the spec]: https://spec.matrix.org/v1.2/client-server-api/#google-recaptcha
|
||||
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[serde(tag = "type", rename = "m.login.recaptcha")]
|
||||
pub struct ReCaptcha<'a> {
|
||||
@ -409,7 +409,7 @@ impl IncomingReCaptcha {
|
||||
/// See [the spec] for how to use this.
|
||||
///
|
||||
/// [the spec]: https://spec.matrix.org/v1.2/client-server-api/#email-based-identity--homeserver
|
||||
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[serde(tag = "type", rename = "m.login.email.identity")]
|
||||
pub struct EmailIdentity<'a> {
|
||||
@ -436,7 +436,7 @@ impl IncomingEmailIdentity {
|
||||
/// See [the spec] for how to use this.
|
||||
///
|
||||
/// [the spec]: https://spec.matrix.org/v1.2/client-server-api/#phone-numbermsisdn-based-identity--homeserver
|
||||
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[serde(tag = "type", rename = "m.login.msisdn")]
|
||||
pub struct Msisdn<'a> {
|
||||
@ -460,7 +460,7 @@ impl IncomingMsisdn {
|
||||
/// See [the spec] for how to use this.
|
||||
///
|
||||
/// [the spec]: https://spec.matrix.org/v1.2/client-server-api/#dummy-auth
|
||||
#[derive(Clone, Debug, Default, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Default, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[serde(tag = "type", rename = "m.login.dummy")]
|
||||
pub struct Dummy<'a> {
|
||||
@ -487,7 +487,7 @@ impl IncomingDummy {
|
||||
/// See [the spec] for how to use this.
|
||||
///
|
||||
/// [the spec]: https://spec.matrix.org/v1.2/client-server-api/#token-authenticated-registration
|
||||
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[serde(tag = "type", rename = "m.login.registration_token")]
|
||||
pub struct RegistrationToken<'a> {
|
||||
@ -517,7 +517,7 @@ impl IncomingRegistrationToken {
|
||||
/// See [the spec] for how to use this.
|
||||
///
|
||||
/// [the spec]: https://spec.matrix.org/v1.2/client-server-api/#fallback
|
||||
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
pub struct FallbackAcknowledgement<'a> {
|
||||
/// The value of the session key given by the homeserver.
|
||||
@ -561,7 +561,7 @@ pub struct IncomingCustomAuthData {
|
||||
}
|
||||
|
||||
/// Identification information for the user.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Incoming, Serialize)]
|
||||
#[serde(from = "user_serde::IncomingUserIdentifier", into = "user_serde::UserIdentifier<'_>")]
|
||||
#[allow(clippy::exhaustive_enums)]
|
||||
pub enum UserIdentifier<'a> {
|
||||
|
@ -1,12 +1,12 @@
|
||||
//! Helper module for the Serialize / Deserialize impl's for the User struct
|
||||
//! in the parent module.
|
||||
|
||||
use ruma_common::{serde::Outgoing, thirdparty::Medium};
|
||||
use ruma_common::{serde::Incoming, thirdparty::Medium};
|
||||
use serde::Serialize;
|
||||
|
||||
// The following structs could just be used in place of the one in the parent module, but
|
||||
// that one is arguably much easier to deal with.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Incoming, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
pub(crate) enum UserIdentifier<'a> {
|
||||
#[serde(rename = "m.id.user")]
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use crate::serde::{Outgoing, StringEnum};
|
||||
use crate::serde::{Incoming, StringEnum};
|
||||
use js_int::UInt;
|
||||
use serde::{
|
||||
de::{Error, MapAccess, Visitor},
|
||||
@ -108,7 +108,7 @@ impl From<PublicRoomsChunkInit> for PublicRoomsChunk {
|
||||
}
|
||||
|
||||
/// A filter for public rooms lists
|
||||
#[derive(Clone, Debug, Default, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Default, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[incoming_derive(Default)]
|
||||
pub struct Filter<'a> {
|
||||
@ -131,7 +131,7 @@ impl Filter<'_> {
|
||||
|
||||
/// Information about which networks/protocols from application services on the
|
||||
/// homeserver from which to request rooms.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Outgoing)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Incoming)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
#[incoming_derive(Clone, PartialEq, Eq, !Deserialize)]
|
||||
pub enum RoomNetwork<'a> {
|
||||
|
@ -73,6 +73,6 @@ where
|
||||
}
|
||||
|
||||
pub use ruma_macros::{
|
||||
AsRefStr, DeserializeFromCowStr, DisplayAsRefStr, FromString, OrdAsRefStr, Outgoing,
|
||||
AsRefStr, DeserializeFromCowStr, DisplayAsRefStr, FromString, Incoming, OrdAsRefStr,
|
||||
PartialEqAsRefStr, PartialOrdAsRefStr, SerializeAsRefStr, StringEnum, _FakeDeriveSerde,
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
#![allow(clippy::exhaustive_structs)]
|
||||
|
||||
#[derive(Copy, Clone, Debug, ruma_common::serde::Outgoing, serde::Serialize)]
|
||||
#[derive(Copy, Clone, Debug, ruma_common::serde::Incoming, serde::Serialize)]
|
||||
pub struct OtherThing<'t> {
|
||||
pub some: &'t str,
|
||||
pub t: &'t [u8],
|
||||
|
@ -4,7 +4,7 @@ use ruma_common::{
|
||||
error::{FromHttpResponseError, IntoHttpError, MatrixError},
|
||||
ruma_api, IncomingResponse, OutgoingResponse,
|
||||
},
|
||||
serde::Outgoing,
|
||||
serde::Incoming,
|
||||
};
|
||||
|
||||
ruma_api! {
|
||||
@ -25,7 +25,7 @@ ruma_api! {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Outgoing)]
|
||||
#[derive(Incoming)]
|
||||
pub struct Response;
|
||||
|
||||
impl IncomingResponse for Response {
|
||||
|
@ -99,7 +99,7 @@ impl Request {
|
||||
Clone,
|
||||
Debug,
|
||||
#ruma_macros::Request,
|
||||
#ruma_common::serde::Outgoing,
|
||||
#ruma_common::serde::Incoming,
|
||||
#ruma_common::serde::_FakeDeriveSerde,
|
||||
)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
|
@ -39,7 +39,7 @@ impl Response {
|
||||
Clone,
|
||||
Debug,
|
||||
#ruma_macros::Response,
|
||||
#ruma_common::serde::Outgoing,
|
||||
#ruma_common::serde::Incoming,
|
||||
#ruma_common::serde::_FakeDeriveSerde,
|
||||
)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
|
@ -220,7 +220,7 @@ impl Request {
|
||||
#serde::Serialize,
|
||||
#derive_deserialize
|
||||
)]
|
||||
#[cfg_attr(feature = "server", derive(#ruma_common::serde::Outgoing))]
|
||||
#[cfg_attr(feature = "server", derive(#ruma_common::serde::Incoming))]
|
||||
#serde_attr
|
||||
struct RequestBody< #(#lifetimes),* > { #(#fields),* }
|
||||
}
|
||||
@ -248,7 +248,7 @@ impl Request {
|
||||
#serde::Serialize,
|
||||
#derive_deserialize
|
||||
)]
|
||||
#[cfg_attr(feature = "server", derive(#ruma_common::serde::Outgoing))]
|
||||
#[cfg_attr(feature = "server", derive(#ruma_common::serde::Incoming))]
|
||||
struct RequestQuery< #(#lifetimes),* > #def
|
||||
}
|
||||
});
|
||||
|
@ -110,7 +110,7 @@ impl Response {
|
||||
#[derive(
|
||||
Debug,
|
||||
#ruma_macros::_FakeDeriveRumaApi,
|
||||
#ruma_common::serde::Outgoing,
|
||||
#ruma_common::serde::Incoming,
|
||||
#serde_derives
|
||||
)]
|
||||
#serde_attr
|
||||
|
@ -37,8 +37,8 @@ use self::{
|
||||
enum_as_ref_str::expand_enum_as_ref_str,
|
||||
enum_from_string::expand_enum_from_string,
|
||||
eq_as_ref_str::expand_partial_eq_as_ref_str,
|
||||
incoming::expand_derive_incoming,
|
||||
ord_as_ref_str::{expand_ord_as_ref_str, expand_partial_ord_as_ref_str},
|
||||
outgoing::expand_derive_outgoing,
|
||||
serialize_as_ref_str::expand_serialize_as_ref_str,
|
||||
},
|
||||
util::import_ruma_common,
|
||||
@ -232,55 +232,13 @@ pub fn user_id(input: TokenStream) -> TokenStream {
|
||||
output.into()
|
||||
}
|
||||
|
||||
/// Derive the `Outgoing` trait, possibly generating an 'Incoming' version of the struct this
|
||||
/// derive macro is used on.
|
||||
/// Generating an 'Incoming' version of the type this derive macro is used on.
|
||||
///
|
||||
/// Specifically, if no lifetime variables are used on any of the fields of the struct, this simple
|
||||
/// implementation will be generated:
|
||||
///
|
||||
/// ```ignore
|
||||
/// # // TODO: "ignore" this doctest until it is more extensively documented. (See #541)
|
||||
/// impl Outgoing for MyType {
|
||||
/// type Incoming = Self;
|
||||
/// }
|
||||
/// ```
|
||||
/*
|
||||
|
||||
TODO: Extend docs. Previously:
|
||||
|
||||
If, however, `#[wrap_incoming]` is used (which is the only reason you should ever use this
|
||||
derive macro manually), a new struct `IncomingT` (where `T` is the type this derive is used on)
|
||||
is generated, with all of the fields with `#[wrap_incoming]` replaced:
|
||||
|
||||
```ignore
|
||||
#[derive(Outgoing)]
|
||||
struct MyType {
|
||||
pub foo: Foo,
|
||||
#[wrap_incoming]
|
||||
pub bar: Bar,
|
||||
#[wrap_incoming(Baz)]
|
||||
pub baz: Option<Baz>,
|
||||
#[wrap_incoming(with EventResult)]
|
||||
pub x: XEvent,
|
||||
#[wrap_incoming(YEvent with EventResult)]
|
||||
pub ys: Vec<YEvent>,
|
||||
}
|
||||
|
||||
// generated
|
||||
struct IncomingMyType {
|
||||
pub foo: Foo,
|
||||
pub bar: IncomingBar,
|
||||
pub baz: Option<IncomingBaz>,
|
||||
pub x: EventResult<XEvent>,
|
||||
pub ys: Vec<EventResult<YEvent>>,
|
||||
}
|
||||
```
|
||||
|
||||
*/
|
||||
#[proc_macro_derive(Outgoing, attributes(incoming_derive))]
|
||||
pub fn derive_outgoing(input: TokenStream) -> TokenStream {
|
||||
/// This type will be a fully-owned version of the input type, using no lifetime generics.
|
||||
#[proc_macro_derive(Incoming, attributes(incoming_derive))]
|
||||
pub fn derive_incoming(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
expand_derive_outgoing(input).unwrap_or_else(syn::Error::into_compile_error).into()
|
||||
expand_derive_incoming(input).unwrap_or_else(syn::Error::into_compile_error).into()
|
||||
}
|
||||
|
||||
/// Derive the `AsRef<str>` trait for an enum.
|
||||
|
@ -7,7 +7,7 @@ pub mod display_as_ref_str;
|
||||
pub mod enum_as_ref_str;
|
||||
pub mod enum_from_string;
|
||||
pub mod eq_as_ref_str;
|
||||
pub mod incoming;
|
||||
pub mod ord_as_ref_str;
|
||||
pub mod outgoing;
|
||||
pub mod serialize_as_ref_str;
|
||||
mod util;
|
||||
|
@ -22,7 +22,7 @@ enum DataKind {
|
||||
Unit,
|
||||
}
|
||||
|
||||
pub fn expand_derive_outgoing(input: DeriveInput) -> syn::Result<TokenStream> {
|
||||
pub fn expand_derive_incoming(input: DeriveInput) -> syn::Result<TokenStream> {
|
||||
let ruma_common = import_ruma_common();
|
||||
|
||||
let mut derives = vec![quote! { Debug }];
|
||||
@ -56,7 +56,7 @@ pub fn expand_derive_outgoing(input: DeriveInput) -> syn::Result<TokenStream> {
|
||||
input.attrs.iter().filter(|attr| filter_input_attrs(attr)).collect::<Vec<_>>();
|
||||
|
||||
let data = match input.data.clone() {
|
||||
Data::Union(_) => panic!("#[derive(Outgoing)] does not support Union types"),
|
||||
Data::Union(_) => panic!("#[derive(Incoming)] does not support Union types"),
|
||||
Data::Enum(e) => DataKind::Enum(e.variants.into_iter().collect()),
|
||||
Data::Struct(s) => match s.fields {
|
||||
Fields::Named(fs) => {
|
@ -13,7 +13,7 @@ pub mod v1 {
|
||||
api::ruma_api,
|
||||
events::RoomEventType,
|
||||
push::{PusherData, Tweak},
|
||||
serde::{Outgoing, StringEnum},
|
||||
serde::{Incoming, StringEnum},
|
||||
EventId, RoomAliasId, RoomId, RoomName, SecondsSinceUnixEpoch, UserId,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -65,7 +65,7 @@ pub mod v1 {
|
||||
}
|
||||
|
||||
/// Type for passing information about a push notification
|
||||
#[derive(Clone, Debug, Default, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Default, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
pub struct Notification<'a> {
|
||||
/// The Matrix event ID of the event being notified about.
|
||||
@ -196,7 +196,7 @@ pub mod v1 {
|
||||
}
|
||||
|
||||
/// Type for passing information about devices.
|
||||
#[derive(Clone, Debug, Deserialize, Outgoing, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, Incoming, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
pub struct Device {
|
||||
/// The `app_id` given when the pusher was created.
|
||||
|
@ -162,7 +162,7 @@ pub use ruma_client::Client;
|
||||
pub use ruma_common::{
|
||||
authentication, device_id, device_key_id, directory, encryption, event_id, matrix_uri, mxc_uri,
|
||||
power_levels, presence, push, receipt, room, room_alias_id, room_id, room_version_id,
|
||||
serde::Outgoing, server_name, server_signing_key_id, thirdparty, to_device, user_id,
|
||||
serde::Incoming, server_name, server_signing_key_id, thirdparty, to_device, user_id,
|
||||
ClientSecret, DeviceId, DeviceKeyAlgorithm, DeviceKeyId, DeviceSignatures, DeviceSigningKeyId,
|
||||
EntitySignatures, EventEncryptionAlgorithm, EventId, KeyId, KeyName, MatrixToUri,
|
||||
MilliSecondsSinceUnixEpoch, MxcUri, PrivOwnedStr, RoomAliasId, RoomId, RoomOrAliasId,
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#![allow(clippy::exhaustive_structs, clippy::redundant_allocation)]
|
||||
|
||||
use ruma::{Outgoing, UserId};
|
||||
use ruma::{Incoming, UserId};
|
||||
|
||||
#[allow(unused)]
|
||||
pub struct Thing<'t, T> {
|
||||
@ -20,14 +20,14 @@ pub struct IncomingThing<T> {
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
#[derive(Copy, Clone, Debug, Outgoing, serde::Serialize)]
|
||||
#[derive(Copy, Clone, Debug, Incoming, serde::Serialize)]
|
||||
#[serde(crate = "serde")]
|
||||
pub struct OtherThing<'t> {
|
||||
pub some: &'t str,
|
||||
pub t: &'t [u8],
|
||||
}
|
||||
|
||||
#[derive(Outgoing)]
|
||||
#[derive(Incoming)]
|
||||
#[incoming_derive(!Deserialize)]
|
||||
#[non_exhaustive]
|
||||
pub struct FakeRequest<'a, T> {
|
||||
@ -45,7 +45,7 @@ pub struct FakeRequest<'a, T> {
|
||||
pub triple_ref: &'a &'a &'a str,
|
||||
}
|
||||
|
||||
#[derive(Outgoing)]
|
||||
#[derive(Incoming)]
|
||||
#[incoming_derive(!Deserialize)]
|
||||
#[non_exhaustive]
|
||||
pub enum EnumThing<'a, T> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user