net/indexeddb/engines/sqlite/
object_store_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"]
11    Table,
12    Id,
13    Name,
14    KeyPath,
15    AutoIncrement,
16}
17
18#[derive(Clone, Debug, Eq, PartialEq)]
19pub struct Model {
20    pub id: i32,
21    pub name: String,
22    pub key_path: Option<Vec<u8>>,
23    pub auto_increment: i32,
24}
25
26impl TryFrom<&Row<'_>> for Model {
27    type Error = rusqlite::Error;
28
29    fn try_from(value: &Row) -> Result<Self, Self::Error> {
30        Ok(Self {
31            id: value.get(0)?,
32            name: value.get(1)?,
33            key_path: value.get(2)?,
34            auto_increment: value.get(3)?,
35        })
36    }
37}