pub enum AuditSink {
Disabled,
File {
path: PathBuf,
max_bytes: Option<u64>,
state: Mutex<FileState>,
},
}Expand description
Where audit events go.
Disabled unless a path is configured: writing to a file nobody asked for would be a surprising side effect, and the operator is the one who knows where such a file belongs.
Variants§
Implementations§
Source§impl AuditSink
impl AuditSink
Sourcepub fn file(path: impl AsRef<Path>) -> Result<Self>
pub fn file(path: impl AsRef<Path>) -> Result<Self>
Open path for appending, creating it if needed.
Sourcepub fn file_with_limit(
path: impl AsRef<Path>,
max_bytes: Option<u64>,
) -> Result<Self>
pub fn file_with_limit( path: impl AsRef<Path>, max_bytes: Option<u64>, ) -> Result<Self>
Open path, rotating to <path>.1 once it passes max_bytes.
One generation is kept. A trail that grows without bound eventually fills the disk it is meant to protect, and keeping several generations would be a retention policy — which belongs to whoever runs the machine, not to this process.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Whether anything is being recorded.
Sourcepub fn record(&self, event: AuditEvent)
pub fn record(&self, event: AuditEvent)
Record one event.
Flushed per event rather than buffered until convenient: a trail that loses its last entries when the process dies is least trustworthy exactly when it matters most.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AuditSink
impl RefUnwindSafe for AuditSink
impl Send for AuditSink
impl Sync for AuditSink
impl Unpin for AuditSink
impl UnsafeUnpin for AuditSink
impl UnwindSafe for AuditSink
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.