app/identity: Make all pub structs non_exhaustive

This commit is contained in:
Devin Ragotzy 2021-06-18 04:15:51 -07:00 committed by GitHub
parent 757ab5273c
commit 5d0803f63d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -103,6 +103,7 @@ pub struct Registration {
///
/// Used for [appservice registration](https://matrix.org/docs/spec/application_service/r0.1.2#registration).
#[derive(Debug)]
#[allow(clippy::exhaustive_structs)]
pub struct RegistrationInit {
/// A unique, user - defined ID of the application service which will never change.
pub id: String,

View File

@ -42,6 +42,7 @@ impl Response {
/// Collection of localized policies.
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct Policies {
/// The version for the policy.
///
@ -57,8 +58,16 @@ pub struct Policies {
pub localized: BTreeMap<String, LocalizedPolicy>,
}
impl Policies {
/// Create a new `Policies` with the given version and localized map.
pub fn new(version: String, localized: BTreeMap<String, LocalizedPolicy>) -> Self {
Self { version, localized }
}
}
/// A localized policy offered by a server.
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct LocalizedPolicy {
/// The localized name of the policy.
///
@ -71,3 +80,10 @@ pub struct LocalizedPolicy {
/// and `https://example.org/somewhere/terms-2.0-fr.html`.
pub url: String,
}
impl LocalizedPolicy {
/// Create a new `LocalizedPolicy` with the given name and url.
pub fn new(name: String, url: String) -> Self {
Self { name, url }
}
}