Skip to content

Commit da7cb21

Browse files
authored
Merge pull request #44 from hnez/import-hack-scopes
tacd: set appropriate pub(super) scopes for demo mode import hacks
2 parents b4e0266 + c80e027 commit da7cb21

File tree

10 files changed

+52
-52
lines changed

10 files changed

+52
-52
lines changed

src/dbus.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,34 @@ use crate::led::BlinkPattern;
2222

2323
#[cfg(feature = "demo_mode")]
2424
mod zb {
25-
pub type Result<T> = std::result::Result<T, ()>;
25+
pub(super) type Result<T> = std::result::Result<T, ()>;
2626

2727
pub struct Connection;
2828
pub struct ConnectionBuilder;
2929

3030
impl ConnectionBuilder {
31-
pub fn system() -> Result<Self> {
31+
pub(super) fn system() -> Result<Self> {
3232
Ok(Self)
3333
}
3434

35-
pub fn name(self, _: &'static str) -> Result<Self> {
35+
pub(super) fn name(self, _: &'static str) -> Result<Self> {
3636
Ok(self)
3737
}
3838

39-
pub fn serve_at<T>(self, _: &'static str, _: T) -> Result<Self> {
39+
pub(super) fn serve_at<T>(self, _: &'static str, _: T) -> Result<Self> {
4040
Ok(self)
4141
}
4242

43-
pub async fn build(self) -> Result<Connection> {
43+
pub(super) async fn build(self) -> Result<Connection> {
4444
Ok(Connection)
4545
}
4646
}
4747
}
4848

4949
#[cfg(not(feature = "demo_mode"))]
5050
mod zb {
51-
pub use zbus::*;
51+
pub(super) use zbus::Result;
52+
pub use zbus::{Connection, ConnectionBuilder};
5253
}
5354

5455
use zb::{Connection, ConnectionBuilder, Result};

src/dbus/networkmanager/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ mod hostname;
2828

2929
// All of the following includes are not used in demo_mode.
3030
// Put them inside a mod so we do not have to decorate each one with
31-
// a #[cfg(not(feature = "demo_mode"))].
31+
#[cfg(not(feature = "demo_mode"))]
3232
mod optional_includes {
33-
pub use anyhow::{anyhow, Result};
34-
pub use async_std::stream::StreamExt;
35-
pub use async_std::task::sleep;
36-
pub use futures::{future::FutureExt, pin_mut, select};
37-
pub use log::trace;
38-
pub use std::convert::TryInto;
39-
pub use std::time::Duration;
40-
pub use zbus::{Connection, PropertyStream};
41-
pub use zvariant::{ObjectPath, OwnedObjectPath};
33+
pub(super) use anyhow::{anyhow, Result};
34+
pub(super) use async_std::stream::StreamExt;
35+
pub(super) use async_std::task::sleep;
36+
pub(super) use futures::{future::FutureExt, pin_mut, select};
37+
pub(super) use log::trace;
38+
pub(super) use std::convert::TryInto;
39+
pub(super) use std::time::Duration;
40+
pub(super) use zbus::{Connection, PropertyStream};
41+
pub(super) use zvariant::{ObjectPath, OwnedObjectPath};
4242
}
4343

4444
#[cfg(not(feature = "demo_mode"))]

src/dbus/rauc/mod.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use installer::InstallerProxy;
4343

4444
#[cfg(feature = "demo_mode")]
4545
mod imports {
46-
pub struct InstallerProxy<'a> {
46+
pub(super) struct InstallerProxy<'a> {
4747
_dummy: &'a (),
4848
}
4949

@@ -60,16 +60,15 @@ mod imports {
6060
}
6161
}
6262

63-
pub const CHANNELS_DIR: &str = "demo_files/usr/share/tacd/update_channels";
63+
pub(super) const CHANNELS_DIR: &str = "demo_files/usr/share/tacd/update_channels";
6464
}
6565

6666
#[cfg(not(feature = "demo_mode"))]
6767
mod imports {
68-
pub use anyhow::{anyhow, bail, Result};
69-
pub use futures::FutureExt;
70-
pub use log::error;
68+
pub(super) use anyhow::{anyhow, bail, Result};
69+
pub(super) use log::error;
7170

72-
pub const CHANNELS_DIR: &str = "/usr/share/tacd/update_channels";
71+
pub(super) const CHANNELS_DIR: &str = "/usr/share/tacd/update_channels";
7372
}
7473

7574
const RELOAD_RATE_LIMIT: Duration = Duration::from_secs(10 * 60);

src/iobus.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ const VOLTAGE_MIN: f32 = 10.0;
3232
mod http {
3333
use super::{LSSState, Nodes, ServerInfo};
3434

35-
pub struct RequestDecoy {}
35+
pub(super) struct RequestDecoy {}
3636

37-
pub trait DemoModeDefault {
37+
pub(super) trait DemoModeDefault {
3838
fn demo_get() -> Self;
3939
}
4040

@@ -62,19 +62,19 @@ mod http {
6262
}
6363

6464
impl RequestDecoy {
65-
pub async fn recv_json<T: DemoModeDefault>(&self) -> Result<T, ()> {
65+
pub(super) async fn recv_json<T: DemoModeDefault>(&self) -> Result<T, ()> {
6666
Ok(T::demo_get())
6767
}
6868
}
6969

70-
pub fn get(_: &str) -> RequestDecoy {
70+
pub(super) fn get(_: &str) -> RequestDecoy {
7171
RequestDecoy {}
7272
}
7373
}
7474

7575
#[cfg(not(feature = "demo_mode"))]
7676
mod http {
77-
pub use surf::get;
77+
pub(super) use surf::get;
7878
}
7979

8080
#[derive(PartialEq, Serialize, Deserialize, Debug, Clone)]

src/journal.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ use tide::{Request, Response, Server};
2828
#[cfg(any(test, feature = "demo_mode"))]
2929
mod sd {
3030
use std::collections::btree_map::BTreeMap;
31-
pub use std::io::Result;
31+
pub(super) use std::io::Result;
3232
use std::io::{Error, ErrorKind};
3333
use std::thread::sleep;
3434
use std::time::{Duration, SystemTime};
3535

36-
pub type JournalRecord = BTreeMap<String, String>;
37-
pub struct Journal;
38-
pub struct OpenOptions;
36+
pub(super) type JournalRecord = BTreeMap<String, String>;
37+
pub(super) struct Journal;
38+
pub(super) struct OpenOptions;
3939

4040
impl OpenOptions {
4141
pub fn default() -> Self {
@@ -88,8 +88,8 @@ mod sd {
8888

8989
#[cfg(not(any(test, feature = "demo_mode")))]
9090
mod sd {
91-
pub use systemd::journal::*;
92-
pub use systemd::*;
91+
pub(super) use systemd::journal::*;
92+
pub(super) use systemd::*;
9393
}
9494

9595
use sd::{Journal, JournalRecord, OpenOptions, Result};

src/temperatures.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ use crate::measurement::Measurement;
2828

2929
#[cfg(feature = "demo_mode")]
3030
mod hw {
31-
pub trait SysClass {
31+
pub(super) trait SysClass {
3232
fn input(&self) -> Result<u32, ()>;
3333
}
3434

35-
pub struct HwMon;
36-
pub struct TempDecoy;
35+
pub(super) struct HwMon;
36+
pub(super) struct TempDecoy;
3737

3838
impl SysClass for TempDecoy {
3939
fn input(&self) -> Result<u32, ()> {
@@ -42,19 +42,19 @@ mod hw {
4242
}
4343

4444
impl HwMon {
45-
pub fn new(_: &'static str) -> Result<Self, ()> {
45+
pub(super) fn new(_: &'static str) -> Result<Self, ()> {
4646
Ok(Self)
4747
}
4848

49-
pub fn temp(&self, _: u64) -> Result<TempDecoy, ()> {
49+
pub(super) fn temp(&self, _: u64) -> Result<TempDecoy, ()> {
5050
Ok(TempDecoy)
5151
}
5252
}
5353
}
5454

5555
#[cfg(not(feature = "demo_mode"))]
5656
mod hw {
57-
pub use sysfs_class::*;
57+
pub(super) use sysfs_class::*;
5858
}
5959

6060
use hw::{HwMon, SysClass};

src/ui/buttons.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ pub const LONG_PRESS: Duration = Duration::from_millis(500);
2828
#[cfg(feature = "demo_mode")]
2929
mod evd {
3030
use evdev::FetchEventsSynced;
31-
pub use evdev::{EventType, InputEventKind, Key};
31+
pub(super) use evdev::{EventType, InputEventKind, Key};
3232

33-
pub struct Device {}
33+
pub(super) struct Device {}
3434

3535
impl Device {
3636
pub fn open(_path: &'static str) -> Result<Self, ()> {
@@ -47,7 +47,7 @@ mod evd {
4747

4848
#[cfg(not(feature = "demo_mode"))]
4949
mod evd {
50-
pub use evdev::*;
50+
pub(super) use evdev::*;
5151
}
5252

5353
use evd::{Device, EventType, InputEventKind, Key};

src/ui/display.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use png::{BitDepth, ColorType, Encoder};
2525
mod backend {
2626
use framebuffer::{FixScreeninfo, VarScreeninfo};
2727

28-
pub struct Framebuffer {
28+
pub(super) struct Framebuffer {
2929
pub device: (),
3030
pub var_screen_info: VarScreeninfo,
3131
pub fix_screen_info: FixScreeninfo,
@@ -58,7 +58,7 @@ mod backend {
5858

5959
#[cfg(not(feature = "demo_mode"))]
6060
mod backend {
61-
pub use framebuffer::*;
61+
pub(super) use framebuffer::*;
6262
}
6363

6464
use backend::Framebuffer;

src/usb_hub.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ mod rw {
6161

6262
static FILESYSTEM: Mutex<Option<HashMap<String, String>>> = Mutex::new(None);
6363

64-
pub fn read_to_string<P: AsRef<Path>>(path: P) -> Result<String> {
64+
pub(super) fn read_to_string<P: AsRef<Path>>(path: P) -> Result<String> {
6565
let path = path.as_ref().to_str().unwrap();
6666

6767
if let Some(stored) = FILESYSTEM
@@ -83,7 +83,7 @@ mod rw {
8383
Ok("0".to_string())
8484
}
8585

86-
pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> Result<()> {
86+
pub(super) fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> Result<()> {
8787
let path: &Path = path.as_ref();
8888
let path = path.to_str().unwrap().to_string();
8989
let contents: &[u8] = contents.as_ref();
@@ -114,7 +114,7 @@ mod rw {
114114

115115
#[cfg(not(feature = "demo_mode"))]
116116
mod rw {
117-
pub use std::fs::*;
117+
pub(super) use std::fs::*;
118118
}
119119

120120
use rw::{read_to_string, write};

src/watchdog.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ use crate::dut_power::TickReader;
2626
mod sd {
2727
use std::io::Result;
2828

29-
pub const STATE_READY: () = ();
30-
pub const STATE_WATCHDOG: () = ();
29+
pub(super) const STATE_READY: () = ();
30+
pub(super) const STATE_WATCHDOG: () = ();
3131

32-
pub fn notify<I>(_: bool, _: I) -> Result<bool> {
32+
pub(super) fn notify<I>(_: bool, _: I) -> Result<bool> {
3333
Ok(true)
3434
}
3535

36-
pub fn watchdog_enabled(_: bool) -> Result<u64> {
36+
pub(super) fn watchdog_enabled(_: bool) -> Result<u64> {
3737
Ok(5_000_000)
3838
}
3939
}
4040

4141
#[cfg(not(any(test, feature = "demo_mode")))]
4242
mod sd {
43-
pub use systemd::daemon::*;
43+
pub(super) use systemd::daemon::*;
4444
}
4545

4646
use sd::{notify, watchdog_enabled, STATE_READY, STATE_WATCHDOG};

0 commit comments

Comments
 (0)