MCPcopy Create free account
hub / github.com/assert-rs/predicates-rs / PredicateFileContentExt

Interface PredicateFileContentExt

src/path/fc.rs:98–119  ·  view source on GitHub ↗

`Predicate` extension adapting a `slice` Predicate.

Source from the content-addressed store, hash-verified

96
97/// `Predicate` extension adapting a `slice` Predicate.
98pub trait PredicateFileContentExt
99where
100 Self: Predicate<[u8]>,
101 Self: Sized,
102{
103 /// Returns a `FileContentPredicate` that adapts `Self` to a file content `Predicate`.
104 ///
105 /// # Examples
106 ///
107 /// ```
108 /// use predicates::prelude::*;
109 /// use std::path::Path;
110 ///
111 /// let predicate_fn = predicate::str::is_empty().not().from_utf8().from_file_path();
112 /// assert_eq!(true, predicate_fn.eval(Path::new("./tests/hello_world")));
113 /// assert_eq!(false, predicate_fn.eval(Path::new("./tests/empty_file")));
114 /// ```
115 #[allow(clippy::wrong_self_convention)]
116 fn from_file_path(self) -> FileContentPredicate<Self> {
117 FileContentPredicate { p: self }
118 }
119}
120
121impl<P> PredicateFileContentExt for P where P: Predicate<[u8]> {}

Callers

nothing calls this directly

Implementers 1

fc.rssrc/path/fc.rs

Calls

no outgoing calls

Tested by

no test coverage detected