You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
635 B
27 lines
635 B
use crate::section_interface::SectionId; |
|
use rusqlite::{Error as SqlError, Row as SqlRow, ToSql}; |
|
use std::sync::Arc; |
|
|
|
#[derive(Debug, Clone)] |
|
pub struct Section { |
|
pub id: u32, |
|
pub name: String, |
|
pub interface_id: SectionId, |
|
} |
|
|
|
impl Section { |
|
pub fn from_sql<'a>(row: &SqlRow<'a>) -> Result<Section, SqlError> { |
|
Ok(Section { |
|
id: row.get(0)?, |
|
name: row.get(1)?, |
|
interface_id: row.get(2)?, |
|
}) |
|
} |
|
|
|
#[allow(dead_code)] |
|
pub fn as_sql(&self) -> Vec<&dyn ToSql> { |
|
vec![&self.id, &self.name, &self.interface_id] |
|
} |
|
} |
|
|
|
pub type SectionRef = Arc<Section>;
|
|
|