pub struct TrustGuard { /* private fields */ }Expand description
Guard that wraps a config file modification to preserve trust.
Snapshots the file’s trust status before the write. After the write,
call TrustGuard::commit to update the trust hash — but only if
the pre-write content was verified as trusted. This prevents a TOCTOU
attack where a malicious actor modifies the file between the last
trust check and rippy’s write.
For newly created files (no prior content), use TrustGuard::for_new_file.
Implementations§
Source§impl TrustGuard
impl TrustGuard
Sourcepub fn before_write(path: &Path) -> Self
pub fn before_write(path: &Path) -> Self
Snapshot the trust state of an existing config file before modifying it.
Reads the file, checks trust status. If the file doesn’t exist yet
(will be created by the write), was_trusted is false.
Sourcepub fn for_new_file(path: &Path) -> Self
pub fn for_new_file(path: &Path) -> Self
Create a guard for a file that is being newly created by the user.
commit() will unconditionally trust the new file since the user
explicitly created it (e.g., rippy init).
Auto Trait Implementations§
impl Freeze for TrustGuard
impl RefUnwindSafe for TrustGuard
impl Send for TrustGuard
impl Sync for TrustGuard
impl Unpin for TrustGuard
impl UnsafeUnpin for TrustGuard
impl UnwindSafe for TrustGuard
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.