matrix_sdk_indexeddb/crypto_store/migrations/v7.rs
1// Copyright 2024 The Matrix.org Foundation C.I.C.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Structs and keys used for reading/writing objects in schema v7
16
17/// The objects we store in the inbound_group_sessions2 indexeddb object
18/// store (in schemas v7 and v8)
19#[derive(Debug, serde::Serialize, serde::Deserialize)]
20pub struct InboundGroupSessionIndexedDbObject2 {
21 /// (Possibly encrypted) serialisation of a
22 /// [`matrix_sdk_crypto::olm::group_sessions::PickledInboundGroupSession`]
23 /// structure.
24 pub pickled_session: Vec<u8>,
25
26 /// Whether the session data has yet to be backed up.
27 ///
28 /// Since we only need to be able to find entries where this is `true`,
29 /// we skip serialization in cases where it is `false`. That has
30 /// the effect of omitting it from the indexeddb index.
31 ///
32 /// We also use a custom serializer because bools can't be used as keys
33 /// in indexeddb.
34 #[serde(
35 default,
36 skip_serializing_if = "std::ops::Not::not",
37 with = "crate::serialize_bool_for_indexeddb"
38 )]
39 pub needs_backup: bool,
40}