sprinklers_rs/src/model/section.rs
2020-08-12 10:01:44 -06:00

22 lines
464 B
Rust

use crate::section_interface::SectionId;
use rusqlite::Row;
use std::convert::TryFrom;
pub struct Section {
pub id: u32,
pub name: String,
pub interface_id: SectionId,
}
impl<'a> TryFrom<&Row<'a>> for Section {
type Error = rusqlite::Error;
fn try_from(row: &Row<'a>) -> Result<Section, Self::Error> {
Ok(Section {
id: row.get(0)?,
name: row.get(1)?,
interface_id: row.get(2)?,
})
}
}