Rename section_interface::SectionId

To SecId
This commit is contained in:
Alex Mikhalev 2020-09-17 20:48:19 -06:00
parent bd643607a9
commit 7cb956c2bd
2 changed files with 11 additions and 11 deletions

View File

@ -1,4 +1,4 @@
use crate::section_interface::SectionId;
use crate::section_interface::SecId;
use rusqlite::{Error as SqlError, Row as SqlRow, ToSql};
use std::sync::Arc;
@ -6,7 +6,7 @@ use std::sync::Arc;
pub struct Section {
pub id: u32,
pub name: String,
pub interface_id: SectionId,
pub interface_id: SecId,
}
impl Section {

View File

@ -2,12 +2,12 @@ use std::iter::repeat_with;
use std::sync::atomic::{AtomicBool, Ordering};
use tracing::debug;
pub type SectionId = u32;
pub type SecId = u32;
pub trait SectionInterface: Send {
fn num_sections(&self) -> SectionId;
fn set_section_state(&self, id: SectionId, running: bool);
fn get_section_state(&self, id: SectionId) -> bool;
fn num_sections(&self) -> SecId;
fn set_section_state(&self, id: SecId, running: bool);
fn get_section_state(&self, id: SecId) -> bool;
}
pub struct MockSectionInterface {
@ -16,7 +16,7 @@ pub struct MockSectionInterface {
impl MockSectionInterface {
#[allow(dead_code)]
pub fn new(num_sections: SectionId) -> Self {
pub fn new(num_sections: SecId) -> Self {
Self {
states: repeat_with(|| AtomicBool::new(false))
.take(num_sections as usize)
@ -26,14 +26,14 @@ impl MockSectionInterface {
}
impl SectionInterface for MockSectionInterface {
fn num_sections(&self) -> SectionId {
self.states.len() as SectionId
fn num_sections(&self) -> SecId {
self.states.len() as SecId
}
fn set_section_state(&self, id: SectionId, running: bool) {
fn set_section_state(&self, id: SecId, running: bool) {
debug!(id, running, "setting section");
self.states[id as usize].store(running, Ordering::SeqCst);
}
fn get_section_state(&self, id: SectionId) -> bool {
fn get_section_state(&self, id: SecId) -> bool {
self.states[id as usize].load(Ordering::SeqCst)
}
}