diff options
Diffstat (limited to 'src/http')
| -rw-r--r-- | src/http/render.rs | 82 | ||||
| -rw-r--r-- | src/http/sse.rs | 35 |
2 files changed, 84 insertions, 33 deletions
diff --git a/src/http/render.rs b/src/http/render.rs index 470125d..4482380 100644 --- a/src/http/render.rs +++ b/src/http/render.rs @@ -1,25 +1,42 @@ use askama::Template; -#[derive(Debug, Clone)] -pub struct Page { - pub title: String, - pub flash: String, - pub has_flash: bool, - pub flash_err: bool, - pub csrf: String, - pub pending: i64, - pub running: i64, - pub attention: i64, - pub nav_reviews: &'static str, - pub nav_builds: &'static str, - pub nav_attention: &'static str, - pub nav_packages: &'static str, - pub nav_subscriptions: &'static str, - pub nav_audit: &'static str, - pub nav_settings: &'static str, - pub gated: bool, +/// The real definition. The module is private, so this `pub` +/// is not a nameable path from outside; the alias below is the +/// only way to reach it, and the alias is what carries the +/// feature-conditional visibility. +mod page { + #[derive(Debug, Clone)] + pub struct Page { + pub title: String, + pub flash: String, + pub has_flash: bool, + pub flash_err: bool, + pub csrf: String, + pub pending: i64, + pub running: i64, + pub attention: i64, + pub nav_reviews: &'static str, + pub nav_builds: &'static str, + pub nav_attention: &'static str, + pub nav_packages: &'static str, + pub nav_subscriptions: &'static str, + pub nav_audit: &'static str, + pub nav_settings: &'static str, + pub gated: bool, + } } +/// The render model's shared header. Every template and route handler that fills it lives inside `http`; the outside readers are the page tests. +/// +/// `pub` only under `test-support`. Production reaches the type +/// through its own module and never names it from outside; the +/// outside reader that needs the name is a test. +#[cfg(feature = "test-support")] +pub use page::Page; + +#[cfg(not(feature = "test-support"))] +pub(crate) use page::Page; + impl Page { pub fn new(title: &str, csrf: String) -> Self { Self { @@ -138,14 +155,31 @@ pub(crate) struct ReviewHead { pub diff_digest: String, } -#[derive(Debug, Clone)] -pub struct Panel { - pub title: String, - pub body: String, - pub empty: bool, - pub empty_note: String, +/// The real definition. The module is private, so this `pub` +/// is not a nameable path from outside; the alias below is the +/// only way to reach it, and the alias is what carries the +/// feature-conditional visibility. +mod panel { + #[derive(Debug, Clone)] + pub struct Panel { + pub title: String, + pub body: String, + pub empty: bool, + pub empty_note: String, + } } +/// A diff panel in the render model. The tests that assert on its body drive a real review and cannot move into the module. +/// +/// `pub` only under `test-support`. Production reaches the type +/// through its own module and never names it from outside; the +/// outside reader that needs the name is a test. +#[cfg(feature = "test-support")] +pub use panel::Panel; + +#[cfg(not(feature = "test-support"))] +pub(crate) use panel::Panel; + impl Panel { pub fn new(title: &str, body: String) -> Self { Self { diff --git a/src/http/sse.rs b/src/http/sse.rs index bceba9f..98e9282 100644 --- a/src/http/sse.rs +++ b/src/http/sse.rs @@ -8,17 +8,34 @@ const MAX_LIFETIME: Duration = Duration::from_secs(30 * 60); const KEEPALIVE: Duration = Duration::from_secs(10); const POLL: Duration = Duration::from_millis(200); -pub struct LogTail { - path: PathBuf, - build_id: String, - db: crate::db::Db, - offset: u64, - out: std::collections::VecDeque<u8>, - started: Instant, - since_keepalive: Duration, - ended: bool, +/// The real definition. The module is private, so this `pub` +/// is not a nameable path from outside; the alias below is the +/// only way to reach it, and the alias is what carries the +/// feature-conditional visibility. +mod log_tail { + pub struct LogTail { + path: PathBuf, + build_id: String, + db: crate::db::Db, + offset: u64, + out: std::collections::VecDeque<u8>, + started: Instant, + since_keepalive: Duration, + ended: bool, + } } +/// The SSE tail handle. The live test that names it drives a real server, so it cannot move into the module. +/// +/// `pub` only under `test-support`. Production reaches the type +/// through its own module and never names it from outside; the +/// outside reader that needs the name is a test. +#[cfg(feature = "test-support")] +pub use log_tail::LogTail; + +#[cfg(not(feature = "test-support"))] +pub(crate) use log_tail::LogTail; + impl LogTail { pub fn new(cfg: &crate::config::Config, db: crate::db::Db, build_id: &str) -> Self { Self { |
