rust_hdf5/format/messages/shared.rs
1//! Shared object header messages (`H5O_shared_t`).
2//!
3//! A message whose header flags carry [`MSG_FLAG_SHARED`] does not hold its
4//! own body. What follows the message header is a *reference* to where the
5//! body really lives — another object header, or the file's shared-message
6//! heap — and decoding those bytes as if they were the body is not a decode
7//! failure but a wrong answer: the first byte of a v2 shared message is the
8//! version `2`, which a datatype decoder reads as version 0, class 2.
9//!
10//! This is how a dataset built on a committed (named) datatype stores its
11//! type: one `H5O_SHARE_TYPE_COMMITTED` reference to the object header of the
12//! datatype it shares.
13//!
14//! The reference itself is decoded by
15//! [`SharedMessagePointer`](crate::format::sohm::SharedMessagePointer), which
16//! the object-header reader resolves through for both storage types; this
17//! module is only the flag that says a body is one.
18
19/// `H5O_MSG_FLAG_SHARED` — the message body is a reference, not the message.
20/// Defined with the rest of the message-envelope flags and re-exported here,
21/// where the readers that consult it look for it.
22pub use super::MSG_FLAG_SHARED;
23
24/// How an object header stores one message, as its flags byte says.
25///
26/// The three cases are what `H5O__debug_real` prints as the message's flags
27/// and, for a shared one, what `H5O__shared_debug` prints beneath it
28/// (H5Odbg.c:409-455, H5Oshared.c:682-706).
29#[derive(Debug, Clone, Copy, PartialEq, Eq)]
30pub enum MessageStorage {
31 /// The body is the message and no index names it.
32 Private,
33 /// [`MSG_FLAG_SHAREABLE`](super::MSG_FLAG_SHAREABLE): the body is still
34 /// the message, and a shared-message index holds an `H5SM_IN_OH` record
35 /// naming it here — the first copy of a share-in-object-header class
36 /// (H5SM.c:1400-1417).
37 Shareable,
38 /// [`MSG_FLAG_SHARED`]: the body is a pointer to where the message
39 /// really lives.
40 Shared(crate::format::sohm::SharedLocation),
41}