storage/indexeddb/engines/sqlite/
object_store_index_model.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4use rusqlite::Row;
5use sea_query::Iden;
6
7#[derive(Iden)]
8#[expect(unused)]
9pub enum Column {
10    #[iden = "object_store_index"]
11    Table,
12    ObjectStoreId,
13    Name,
14    KeyPath,
15    UniqueIndex,
16    MultiEntryIndex,
17}
18
19#[derive(Clone, Debug, Eq, PartialEq)]
20pub struct Model {
21    pub id: i32,
22    pub object_store_id: i32,
23    pub name: String,
24    pub key_path: Vec<u8>,
25    pub unique_index: bool,
26    pub multi_entry_index: bool,
27}
28
29impl TryFrom<&Row<'_>> for Model {
30    type Error = rusqlite::Error;
31
32    fn try_from(value: &Row) -> Result<Self, Self::Error> {
33        Ok(Self {
34            id: value.get(0)?,
35            object_store_id: value.get(1)?,
36            name: value.get(2)?,
37            key_path: value.get(3)?,
38            unique_index: value.get(4)?,
39            multi_entry_index: value.get(5)?,
40        })
41    }
42}