sprinklers_rs/src/model/section.rs
Alex Mikhalev 53bd7c6679
All checks were successful
continuous-integration/drone/push Build is passing
Fix dead code warnings
2020-08-17 22:23:45 -06:00

28 lines
635 B
Rust

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>;