Skip to content

Decode tag values into buffer#325

Merged
197g merged 3 commits intomainfrom
decode-values-into-buffer
Jan 11, 2026
Merged

Decode tag values into buffer#325
197g merged 3 commits intomainfrom
decode-values-into-buffer

Conversation

@197g
Copy link
Member

@197g 197g commented Jan 11, 2026

Two new methods for IfdDecoder:

  • find_tag_buf(&mut self, &mut ValueBuffer) -> Result<Option<Entry>, _>
  • find_tag_bytes(&mut self, buf: &mut [u8], offset: u64) -> Result<Option<usize>, _>

Both will only access bytes belonging to the tag entry if present. The former returns the entry itself as convenience. It must be an option for case the tag is missing, which we want to signal as success and Entry occurs naturally. Most of the information would be present on the buffer afterwards though. The byte version returns the number of bytes that have been written. You're expected to have called find_entry to allocate the buffer so the entry itself will likely not provide new information.

Note that find_tag_buf is not implemented in terms of the other since there is a potential optimization that delays allocating the buffer until we found that the reader actually has enough data present. (Similar to <dyn Read>::read_to_end). We always enforce the limit so this is pure optimization left for later.

@197g 197g changed the title Decode values into buffer Decode tag values into buffer Jan 11, 2026
@197g 197g merged commit cf68042 into main Jan 11, 2026
15 checks passed
@197g 197g deleted the decode-values-into-buffer branch January 11, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant