@@ -40,11 +40,11 @@ pub enum Error {
4040
4141/// Additional information for use in the [`State::apply()`] method.
4242#[ derive( Debug , Copy , Clone ) ]
43- pub struct Context < ' a > {
43+ pub struct Context < ' a , ' b > {
4444 /// The repo-relative using slashes as separator of the entry currently being processed.
4545 pub rela_path : & ' a BStr ,
4646 /// The name of the reference that `HEAD` is pointing to. It's passed to `process` filters if present.
47- pub ref_name : Option < & ' a BStr > ,
47+ pub ref_name : Option < & ' b BStr > ,
4848 /// The root-level tree that contains the current entry directly or indirectly, or the commit owning the tree (if available).
4949 ///
5050 /// This is passed to `process` filters if present.
@@ -58,6 +58,7 @@ pub struct Context<'a> {
5858impl State {
5959 /// Apply `operation` of `driver` to the bytes read from `src` and return a reader to immediately consume the output
6060 /// produced by the filter. `rela_path` is the repo-relative path of the entry to handle.
61+ /// It's possible that the filter stays inactive, in which case the `src` isn't consumed and has to be used by the caller.
6162 ///
6263 /// Each call to this method will cause the corresponding filter to be invoked unless `driver` indicates a `process` filter,
6364 /// which is only launched once and maintained using this state.
@@ -74,9 +75,9 @@ impl State {
7475 pub fn apply < ' a > (
7576 & ' a mut self ,
7677 driver : & Driver ,
77- src : impl std:: io:: Read ,
78+ src : & mut impl std:: io:: Read ,
7879 operation : Operation ,
79- ctx : Context < ' _ > ,
80+ ctx : Context < ' _ , ' _ > ,
8081 ) -> Result < Option < Box < dyn std:: io:: Read + ' a > > , Error > {
8182 match self . apply_delayed ( driver, src, operation, Delay :: Forbid , ctx) ? {
8283 Some ( MaybeDelayed :: Delayed ( _) ) => {
@@ -94,14 +95,14 @@ impl State {
9495 pub fn apply_delayed < ' a > (
9596 & ' a mut self ,
9697 driver : & Driver ,
97- mut src : impl std:: io:: Read ,
98+ src : & mut impl std:: io:: Read ,
9899 operation : Operation ,
99100 delay : Delay ,
100- ctx : Context < ' _ > ,
101+ ctx : Context < ' _ , ' _ > ,
101102 ) -> Result < Option < MaybeDelayed < ' a > > , Error > {
102- match self . process ( driver, operation, ctx. rela_path ) ? {
103+ match self . maybe_launch_process ( driver, operation, ctx. rela_path ) ? {
103104 Some ( Process :: SingleFile { mut child, command } ) => {
104- std:: io:: copy ( & mut src, & mut child. stdin . take ( ) . expect ( "configured" ) ) ?;
105+ std:: io:: copy ( src, & mut child. stdin . take ( ) . expect ( "configured" ) ) ?;
105106 Ok ( Some ( MaybeDelayed :: Immediate ( Box :: new ( ReadFilterOutput {
106107 inner : child. stdout . take ( ) ,
107108 child : driver. required . then_some ( ( child, command) ) ,
@@ -179,7 +180,7 @@ impl State {
179180 }
180181}
181182
182- /// A utility type to represent delayed or immediate apply-filter results.
183+ /// A type to represent delayed or immediate apply-filter results.
183184pub enum MaybeDelayed < ' a > {
184185 /// Using the delayed protocol, this entry has been sent to a long-running process and needs to be
185186 /// checked for again, later, using the [`driver::Key`] to refer to the filter who owes a response.
0 commit comments