net/indexeddb/engines/sqlite/
object_data_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)]
8pub enum Column {
9    #[iden = "object_data"]
10    Table,
11    ObjectStoreId,
12    Key,
13    Data,
14}
15
16#[derive(Clone, Debug, Eq, PartialEq)]
17pub struct Model {
18    pub object_store_id: i32,
19    pub key: Vec<u8>,
20    pub data: Vec<u8>,
21}
22
23impl TryFrom<&Row<'_>> for Model {
24    type Error = rusqlite::Error;
25
26    fn try_from(value: &Row) -> Result<Self, Self::Error> {
27        Ok(Self {
28            object_store_id: value.get(0)?,
29            key: value.get(1)?,
30            data: value.get(2)?,
31        })
32    }
33}