pub struct LogStore {
pub dir: PathBuf,
pub quota_bytes: u64,
}Expand description
Manages the on-disk log storage directory and disk-quota policy.
Cheap to clone — only holds a PathBuf and a u64.
Fields§
§dir: PathBufDirectory where task logs are stored.
quota_bytes: u64Maximum total size of all logs before oldest-first eviction.
Implementations§
Source§impl LogStore
impl LogStore
Sourcepub fn new(dir: PathBuf, quota_bytes: u64) -> Self
pub fn new(dir: PathBuf, quota_bytes: u64) -> Self
Create a new LogStore pointing at dir with the given quota.
The directory is created lazily on first write.
Sourcepub async fn open_writer(&self, task_id: TaskId) -> Result<LogWriter>
pub async fn open_writer(&self, task_id: TaskId) -> Result<LogWriter>
Open a new LogWriter for task_id, creating the directory if
needed. Any pre-existing log for this task ID is overwritten.
Sourcepub async fn list_entries(&self) -> Result<Vec<LogEntry>>
pub async fn list_entries(&self) -> Result<Vec<LogEntry>>
List all log entries (.log and .log.gz) in the store directory.
Returns an empty Vec if the directory does not yet exist.
Sourcepub async fn total_size(&self) -> Result<u64>
pub async fn total_size(&self) -> Result<u64>
Total disk usage across all log files.
Sourcepub async fn enforce_quota(&self) -> Result<Vec<PathBuf>>
pub async fn enforce_quota(&self) -> Result<Vec<PathBuf>>
Delete oldest log files until total usage is within Self::quota_bytes.
Returns the paths of all deleted files.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LogStore
impl RefUnwindSafe for LogStore
impl Send for LogStore
impl Sync for LogStore
impl Unpin for LogStore
impl UnsafeUnpin for LogStore
impl UnwindSafe for LogStore
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more