pub struct Header<C: HeaderChecker> { /* private fields */ }
Expand description
A file header to check for, or add to, files.
Implementations§
Source§impl<C: HeaderChecker> Header<C>
impl<C: HeaderChecker> Header<C>
Sourcepub fn new(checker: C, header: String) -> Self
pub fn new(checker: C, header: String) -> Self
Construct a new Header
with the checker
used to determine if the header is already
present, and the plain header
text to add.
header
does not need to have applicable comment syntax, etc, as that will be added for
each file type encountered.
Sourcepub fn header_present(&self, input: &mut impl Read) -> Result<bool>
pub fn header_present(&self, input: &mut impl Read) -> Result<bool>
Return true
if the file has the desired header, false otherwise.
Sourcepub fn add_header_if_missing(&self, p: &Path) -> Result<bool, AddHeaderError>
pub fn add_header_if_missing(&self, p: &Path) -> Result<bool, AddHeaderError>
Add the header, with appropriate formatting for the type of file indicated by p
’s
extension, if the header is not already present.
Returns true
if the header was added.
Sourcepub fn delete_header_if_present(
&self,
p: &Path,
) -> Result<bool, DeleteHeaderError>
pub fn delete_header_if_present( &self, p: &Path, ) -> Result<bool, DeleteHeaderError>
Delete the header, with appropriate formatting for the type of file indicated by p
’s
extension, if the header is already present.
Returns true
if the header was deleted.
Trait Implementations§
Auto Trait Implementations§
impl<C> Freeze for Header<C>where
C: Freeze,
impl<C> RefUnwindSafe for Header<C>where
C: RefUnwindSafe,
impl<C> Send for Header<C>
impl<C> Sync for Header<C>where
C: Sync,
impl<C> Unpin for Header<C>where
C: Unpin,
impl<C> UnwindSafe for Header<C>where
C: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more