Remove borrowing from API responses
To borrow these with correct lifetimes, we would need GATs
This commit is contained in:
parent
ade12dec47
commit
f37fc6845f
@ -21,10 +21,10 @@ ruma_api! {
|
||||
|
||||
response: {
|
||||
/// The room ID for this room alias.
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: RoomId,
|
||||
|
||||
/// A list of servers that are aware of this room ID.
|
||||
pub servers: &'a [String],
|
||||
pub servers: Vec<String>,
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
|
@ -6,34 +6,33 @@ pub mod get_room_visibility;
|
||||
pub mod set_room_visibility;
|
||||
|
||||
use js_int::UInt;
|
||||
use ruma_api::Outgoing;
|
||||
use ruma_identifiers::{RoomAliasId, RoomId};
|
||||
use serde::Serialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A chunk of a room list response, describing one room
|
||||
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||
pub struct PublicRoomsChunk<'a> {
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct PublicRoomsChunk {
|
||||
/// Aliases of the room.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub aliases: Vec<&'a RoomAliasId>,
|
||||
pub aliases: Vec<RoomAliasId>,
|
||||
|
||||
/// The canonical alias of the room, if any.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub canonical_alias: Option<&'a RoomAliasId>,
|
||||
pub canonical_alias: Option<RoomAliasId>,
|
||||
|
||||
/// The name of the room, if any.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub name: Option<&'a str>,
|
||||
pub name: Option<String>,
|
||||
|
||||
/// The number of members joined to the room.
|
||||
pub num_joined_members: UInt,
|
||||
|
||||
/// The ID of the room.
|
||||
pub room_id: &'a RoomId,
|
||||
pub room_id: RoomId,
|
||||
|
||||
/// The topic of the room, if any.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub topic: Option<&'a str>,
|
||||
pub topic: Option<String>,
|
||||
|
||||
/// Whether the room may be viewed by guest users without joining.
|
||||
pub world_readable: bool,
|
||||
@ -45,5 +44,5 @@ pub struct PublicRoomsChunk<'a> {
|
||||
|
||||
/// The URL for the room's avatar, if one is set.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub avatar_url: Option<&'a str>,
|
||||
pub avatar_url: Option<String>,
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
use js_int::UInt;
|
||||
use ruma_api::ruma_api;
|
||||
|
||||
use super::{IncomingPublicRoomsChunk, PublicRoomsChunk};
|
||||
use super::PublicRoomsChunk;
|
||||
|
||||
ruma_api! {
|
||||
metadata: {
|
||||
@ -36,13 +36,13 @@ ruma_api! {
|
||||
|
||||
response: {
|
||||
/// A paginated chunk of public rooms.
|
||||
pub chunk: Vec<PublicRoomsChunk<'a>>,
|
||||
pub chunk: Vec<PublicRoomsChunk>,
|
||||
|
||||
/// A pagination token for the response.
|
||||
pub next_batch: Option<&'a str>,
|
||||
pub next_batch: Option<String>,
|
||||
|
||||
/// A pagination token that allows fetching previous results.
|
||||
pub prev_batch: Option<&'a str>,
|
||||
pub prev_batch: Option<String>,
|
||||
|
||||
/// An estimate on the total number of public rooms, if the server has an estimate.
|
||||
pub total_room_count_estimate: Option<UInt>,
|
||||
@ -73,8 +73,8 @@ fn construct_response_from_refs() {
|
||||
|
||||
let res: http::Response<Vec<u8>> = Response {
|
||||
chunk: vec![],
|
||||
next_batch: Some("next_batch_token"),
|
||||
prev_batch: Some("prev_batch_token"),
|
||||
next_batch: Some("next_batch_token".into()),
|
||||
prev_batch: Some("prev_batch_token".into()),
|
||||
total_room_count_estimate: Some(js_int::uint!(10)),
|
||||
}
|
||||
.try_into()
|
||||
|
@ -12,7 +12,7 @@ use serde::{
|
||||
|
||||
use serde_json::Value as JsonValue;
|
||||
|
||||
use super::{IncomingPublicRoomsChunk, PublicRoomsChunk};
|
||||
use super::PublicRoomsChunk;
|
||||
|
||||
ruma_api! {
|
||||
metadata: {
|
||||
@ -51,13 +51,13 @@ ruma_api! {
|
||||
|
||||
response: {
|
||||
/// A paginated chunk of public rooms.
|
||||
pub chunk: Vec<PublicRoomsChunk<'a>>,
|
||||
pub chunk: Vec<PublicRoomsChunk>,
|
||||
|
||||
/// A pagination token for the response.
|
||||
pub next_batch: Option<&'a str>,
|
||||
pub next_batch: Option<String>,
|
||||
|
||||
/// A pagination token that allows fetching previous results.
|
||||
pub prev_batch: Option<&'a str>,
|
||||
pub prev_batch: Option<String>,
|
||||
|
||||
/// An estimate on the total number of public rooms, if the server has an estimate.
|
||||
pub total_room_count_estimate: Option<UInt>,
|
||||
|
@ -27,11 +27,11 @@ ruma_api! {
|
||||
|
||||
response: {
|
||||
/// The Matrix User IDs of all users who updated their device identity keys.
|
||||
pub changed: &'a [UserId],
|
||||
pub changed: Vec<UserId>,
|
||||
|
||||
/// The Matrix User IDs of all users who may have left all the end-to-end
|
||||
/// encrypted rooms they previously shared with the user.
|
||||
pub left: &'a [UserId],
|
||||
pub left: Vec<UserId>,
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
|
@ -41,7 +41,7 @@ ruma_api! {
|
||||
|
||||
response: {
|
||||
/// A unique identifier for the event.
|
||||
pub event_id: &'a EventId,
|
||||
pub event_id: EventId,
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
|
@ -20,7 +20,7 @@ ruma_api! {
|
||||
}
|
||||
|
||||
response: {
|
||||
aliases: &'a [RoomAliasId],
|
||||
aliases: Vec<RoomAliasId>,
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
|
@ -33,7 +33,7 @@ ruma_api! {
|
||||
|
||||
response: {
|
||||
/// A unique identifier for the event.
|
||||
pub event_id: &'a EventId,
|
||||
pub event_id: EventId,
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
|
@ -37,7 +37,7 @@ ruma_api! {
|
||||
|
||||
response: {
|
||||
/// A unique identifier for the event.
|
||||
pub event_id: &'a EventId,
|
||||
pub event_id: EventId,
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
|
@ -1,9 +1,9 @@
|
||||
//! [POST /_matrix/client/r0/user_directory/search](https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-user-directory-search)
|
||||
|
||||
use js_int::{uint, UInt};
|
||||
use ruma_api::{ruma_api, Outgoing};
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::UserId;
|
||||
use serde::Serialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
ruma_api! {
|
||||
metadata: {
|
||||
@ -28,7 +28,7 @@ ruma_api! {
|
||||
|
||||
response: {
|
||||
/// Ordered by rank and then whether or not profile info is available.
|
||||
pub results: &'a [User<'a>],
|
||||
pub results: Vec<User>,
|
||||
|
||||
/// Indicates if the result list has been truncated by the limit.
|
||||
pub limited: bool,
|
||||
@ -46,16 +46,16 @@ fn is_default_limit(limit: &UInt) -> bool {
|
||||
}
|
||||
|
||||
/// User data as result of a search.
|
||||
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||
pub struct User<'a> {
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct User {
|
||||
/// The user's matrix user ID.
|
||||
pub user_id: &'a UserId,
|
||||
pub user_id: UserId,
|
||||
|
||||
/// The display name of the user, if one exists.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub display_name: Option<&'a str>,
|
||||
pub display_name: Option<String>,
|
||||
|
||||
/// The avatar url, as an MXC, if one exists.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub avatar_url: Option<&'a str>,
|
||||
pub avatar_url: Option<String>,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user