Method
try_new
(
cached_file_list: CachedFileList,
ttl: Option<Duration>,
now: Instant,
)
Source from the content-addressed store, hash-verified
| 102 | |
| 103 | impl ListFilesEntry { |
| 104 | fn try_new( |
| 105 | cached_file_list: CachedFileList, |
| 106 | ttl: Option<Duration>, |
| 107 | now: Instant, |
| 108 | ) -> Option<Self> { |
| 109 | let size_bytes = (cached_file_list.files.capacity() * size_of::<ObjectMeta>()) |
| 110 | + cached_file_list |
| 111 | .files |
| 112 | .iter() |
| 113 | .map(meta_heap_bytes) |
| 114 | .reduce(|acc, b| acc + b)?; |
| 115 | |
| 116 | Some(Self { |
| 117 | metas: cached_file_list, |
| 118 | size_bytes, |
| 119 | expires: ttl.map(|t| now + t), |
| 120 | }) |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | /// Calculates the number of bytes an [`ObjectMeta`] occupies in the heap. |
Callers
nothing calls this directly
Tested by
no test coverage detected