thirdparty: Fix unstable-unspecified feature being non-additive

This commit is contained in:
Kévin Commaille 2024-06-18 12:35:59 +02:00 committed by Kévin Commaille
parent 6347f547c1
commit 64b3838113
2 changed files with 10 additions and 15 deletions

View File

@ -1,5 +1,11 @@
# [unreleased]
Bug fixes:
- The `instance_id` field was removed from `ProtocolInstanceInit` and is now an
`Option<String>` for `ProtocolInstance`. It made the `unstable-unspecified`
feature non-additive.
Improvements:
- Add the `InvalidHeaderValue` variant to the `DeserializationError` struct, for

View File

@ -91,7 +91,8 @@ pub struct ProtocolInstance {
///
/// See [matrix-spec#833](https://github.com/matrix-org/matrix-spec/issues/833).
#[cfg(feature = "unstable-unspecified")]
pub instance_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub instance_id: Option<String>,
}
/// Initial set of fields of `Protocol`.
@ -109,30 +110,18 @@ pub struct ProtocolInstanceInit {
/// A unique identifier across all instances.
pub network_id: String,
/// A unique identifier across all instances.
///
/// See [matrix-spec#833](https://github.com/matrix-org/matrix-spec/issues/833).
#[cfg(feature = "unstable-unspecified")]
pub instance_id: String,
}
impl From<ProtocolInstanceInit> for ProtocolInstance {
fn from(init: ProtocolInstanceInit) -> Self {
let ProtocolInstanceInit {
desc,
fields,
network_id,
#[cfg(feature = "unstable-unspecified")]
instance_id,
} = init;
let ProtocolInstanceInit { desc, fields, network_id } = init;
Self {
desc,
icon: None,
fields,
network_id,
#[cfg(feature = "unstable-unspecified")]
instance_id,
instance_id: None,
}
}
}