Add Directory::is_empty for completeness

This commit is contained in:
A. Molzer committed 2025-07-14 19:56:06 +02:00
1 parent 46e51cc67e
commit a3c81e9830
1 file changed
+8
+8
View File
@@ -27,6 +27,8 @@ pub struct Directory {
} }
impl Directory { impl Directory {
/// Create a directory in an initial state without entries. Note that an empty directory can
/// not be encoded in a file, it must contain at least one entry.
pub fn empty() -> Self { pub fn empty() -> Self {
Directory { Directory {
entries: BTreeMap::new(), entries: BTreeMap::new(),
@@ -72,6 +74,12 @@ impl Directory {
self.entries.len() self.entries.len()
} }
/// Check if there are any entries in this directory. Note that an empty directory can not be
/// encoded in the file, it must contain at least one entry.
pub fn is_empty(&self) -> bool {
self.entries.is_empty()
}
/// Get the pointer to the next IFD, if it was defined. /// Get the pointer to the next IFD, if it was defined.
pub fn next(&self) -> Option<IfdPointer> { pub fn next(&self) -> Option<IfdPointer> {
self.next_ifd.map(|n| IfdPointer(n.get())) self.next_ifd.map(|n| IfdPointer(n.get()))