1717//! queue untouched. Half-applying a mangled review would lose memories with
1818//! no way to tell which.
1919
20- use crate :: extras:: memory_db:: { PendingEntry , SqliteMemoryStore } ;
20+ #[ cfg( unix) ]
21+ use crate :: extras:: memory_db:: PendingEntry ;
22+ use crate :: extras:: memory_db:: SqliteMemoryStore ;
2123
24+ #[ cfg( unix) ]
2225const HEADER : & str = "\
2326 # Memory review
2427#
@@ -34,12 +37,14 @@ const HEADER: &str = "\
3437
3538/// Where an entry lives: which store, which target within it.
3639#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
40+ #[ cfg( unix) ]
3741pub struct Section {
3842 pub global : bool ,
3943 /// `"memory"` or `"pitfalls"`.
4044 pub target : & ' static str ,
4145}
4246
47+ #[ cfg( unix) ]
4348impl Section {
4449 fn heading ( & self ) -> String {
4550 format ! (
@@ -70,13 +75,15 @@ impl Section {
7075
7176/// One reviewed entry, as parsed back out of the document.
7277#[ derive( Debug , Clone , PartialEq , Eq ) ]
78+ #[ cfg( unix) ]
7379pub struct ReviewedEntry {
7480 pub section : Section ,
7581 pub kind : Option < String > ,
7682 pub content : String ,
7783}
7884
7985/// Render the queue for editing. `entries` is `(section, pending)` pairs.
86+ #[ cfg( unix) ]
8087pub fn render ( entries : & [ ( Section , PendingEntry ) ] ) -> String {
8188 let mut out = String :: from ( HEADER ) ;
8289 let mut current: Option < Section > = None ;
@@ -95,6 +102,7 @@ pub fn render(entries: &[(Section, PendingEntry)]) -> String {
95102/// Errors rather than guessing: a block that appears before any heading has
96103/// no home, and an unrecognized heading would silently swallow everything
97104/// under it.
105+ #[ cfg( unix) ]
98106pub fn parse ( text : & str ) -> Result < Vec < ReviewedEntry > , String > {
99107 let mut out: Vec < ReviewedEntry > = Vec :: new ( ) ;
100108 let mut section: Option < Section > = None ;
@@ -151,11 +159,11 @@ pub fn parse(text: &str) -> Result<Vec<ReviewedEntry>, String> {
151159 continue ;
152160 }
153161 // An indented line continues the block above it.
154- if line. starts_with ( ' ' ) || line. starts_with ( '\t' ) {
155- if let Some ( ( _, lines) ) = pending. as_mut ( ) {
156- lines . push ( trimmed . trim ( ) . to_string ( ) ) ;
157- continue ;
158- }
162+ if ( line. starts_with ( ' ' ) || line. starts_with ( '\t' ) )
163+ && let Some ( ( _, lines) ) = pending. as_mut ( )
164+ {
165+ lines . push ( trimmed . trim ( ) . to_string ( ) ) ;
166+ continue ;
159167 }
160168 flush ( & mut out, section, pending. take ( ) ) ?;
161169 let ( kind, rest) = split_kind ( trimmed. trim ( ) ) ;
@@ -168,6 +176,7 @@ pub fn parse(text: &str) -> Result<Vec<ReviewedEntry>, String> {
168176/// Split a leading `[kind]` marker off a block's first line. A block with no
169177/// marker is accepted with `kind = None` so a human can type a bare line and
170178/// let the store pick the default.
179+ #[ cfg( unix) ]
171180fn split_kind ( line : & str ) -> ( Option < String > , & str ) {
172181 if let Some ( rest) = line. strip_prefix ( '[' )
173182 && let Some ( ( kind, tail) ) = rest. split_once ( ']' )
@@ -179,6 +188,7 @@ fn split_kind(line: &str) -> (Option<String>, &str) {
179188
180189/// What an applied review did.
181190#[ derive( Debug , Default , PartialEq , Eq ) ]
191+ #[ cfg( unix) ]
182192pub struct ApplyReport {
183193 pub stored : usize ,
184194 pub rejected : usize ,
@@ -187,6 +197,7 @@ pub struct ApplyReport {
187197 pub failures : Vec < String > ,
188198}
189199
200+ #[ cfg( unix) ]
190201impl ApplyReport {
191202 pub fn summary ( & self ) -> String {
192203 let mut s = format ! ( "{} stored, {} rejected" , self . stored, self . rejected) ;
@@ -203,6 +214,7 @@ impl ApplyReport {
203214/// defaults, threat scanning and FTS indexing behave exactly as they do for
204215/// an unreviewed write — an entry the human typed is indistinguishable from
205216/// one the model proposed, which is the point.
217+ #[ cfg( unix) ]
206218pub fn apply (
207219 project : & SqliteMemoryStore ,
208220 global : Option < & SqliteMemoryStore > ,
@@ -247,6 +259,7 @@ pub fn apply(
247259 report
248260}
249261
262+ #[ cfg( unix) ]
250263fn truncate ( s : & str ) -> String {
251264 if s. chars ( ) . count ( ) <= 48 {
252265 return s. to_string ( ) ;
@@ -275,6 +288,7 @@ pub fn notify_if_queued(paths: &crate::extras::dirge_paths::ProjectPaths) {
275288}
276289
277290/// Collect the queue from both stores, in a stable order.
291+ #[ cfg( unix) ]
278292pub fn collect (
279293 project : & SqliteMemoryStore ,
280294 global : Option < & SqliteMemoryStore > ,
@@ -304,7 +318,7 @@ pub fn collect(
304318 out
305319}
306320
307- #[ cfg( test) ]
321+ #[ cfg( all ( test, unix ) ) ]
308322mod tests {
309323 use super :: * ;
310324
0 commit comments