Expand description
Content protocol: protobuf ItemMessage encoding/decoding, mixin
construction, deterministic item-id derivation, and CID <-> sha2-256-digest
conversion.
On-chain content is a protobuf ItemMessage: an ordered list of
MixinPayloadMessage { mixin_id, payload }, each tagged with a 32-bit mixin
ID. The semantic type of an item is implied by which mixins are present
(a feed/comment type marker, a profile mixin, etc.), so the same
encoding serves a decentralized GitHub, a decentralized Wiki, or arbitrary
content — only the mixin set differs.
The 32-byte IpfsHash stored on-chain is the sha2-256 digest of an item’s
bytes, extracted from an IPFS CIDv0 multihash (0x12 0x20 || digest). This
module converts between the CID (Base58, as IPFS returns) and the digest hex
(0x-prefixed) that is what actually reaches the chain events.
Structs§
- Body
Text Mixin Message - Body text.
- Content
Input - Input to a publish: everything a caller wants in a new item revision.
- Decoded
Item - The decoded, field-extracted view of an item (what a read tool returns).
- Image
Input - Caller-supplied image reference for a publish.
- Image
Mixin Message - An image reference plus its mipmap pyramid (each level a separate IPFS CID).
- Image
Spec - Structured image reference carried in an item.
- Item
Message - The top-level content envelope: an ordered list of mixins.
- Language
Mixin Message - BCP-47 language tag.
- Mipmap
Level - A mipmap level of an image, as uploaded to IPFS (a pre-encoded CID per level).
- Mipmap
Level Message - One mipmap level of an
ImageMixinMessage. - Mixin
Payload Message - A single tagged mixin: a 32-bit type discriminator plus its payload.
- Prepared
Content - A
ContentInputwhose image reference has been resolved into a completeImageSpec— the inputencode_itemactually encodes. Built viaContentInput::to_prepared(usually through the orchestration layer, which performs the IPFS work forpath-based inputs). - Profile
Mixin Message - Account profile mixin: signed account type + free-text location.
- Profile
Spec - Structured profile fields.
- Title
Mixin Message - Human-readable title.
Enums§
- Account
Type - The account-type taxonomy encoded in a
ProfileMixinMessage. - Content
Type - Fixed, protocol-level content-type vocabulary. The type is encoded by
which mixins an item carries; this enum is the closure over the known
marker/profile mixins.
Documentis the default (title + body + language).
Constants§
- BODY_
TEXT_ MIXIN_ ID - Body text (markdown/plain).
- COMMENT_
TYPE_ MIXIN_ ID - Comment-type marker (empty payload).
- DEFAULT_
LANGUAGE_ TAG - Default BCP-47 language tag applied when the caller omits one.
- FEED_
TYPE_ MIXIN_ ID - Feed-type marker (empty payload).
- IMAGE_
MIXIN_ ID - Image (full-res + mipmap levels).
- LANGUAGE_
MIXIN_ ID - BCP-47 language tag.
- PROFILE_
MIXIN_ ID - Profile (account type + location), used alongside title/body/language.
- TITLE_
MIXIN_ ID - Human-readable title.
Functions§
- bytes_
to_ cid - Raw 32-byte digest -> IPFS
CIDv0(Base58). - bytes_
to_ hex [u8; 32]->0x-prefixed hex string.- cid_
to_ digest_ hex - IPFS
CIDv0(Base58 sha2-256) ->0x-prefixed digest hex. - decode_
image_ mixin - Decode an
ImageMixinMessagepayload into anImageSpec, converting each level’s digest back to a CID for display. - decode_
item - Decode
ItemMessagebytes into an extractedDecodedItem. Unknown mixins are ignored (forward compatibility); a missing/ill-formed mixin degrades that field toNonerather than failing the whole decode. - decode_
single_ mixin - Extract a single mixin’s payload by ID.
- derive_
item_ id - Derive a deterministic item ID from the publishing account, a caller- supplied nonce, and the fixed namespace:
- digest_
hex_ to_ cid - sha2-256 digest hex (
0x) -> IPFSCIDv0(Base58), prefixing the0x12 0x20multihash header. - encode_
image_ mixin - Encode an
ImageSpecinto theImageMixinMessagepayload bytes. - encode_
item - Encode a
ContentInputinto the protobufItemMessagebytes, tagging the right mixin set for the chosenContentType. - hex_
to_ bytes 0x-prefixed hex (32 bytes) ->[u8; 32].- infer_
content_ type - Infer the
ContentTypeof a decoded item from its marker/profile mixins. - short_
hex - Abbreviate a long hex string to
first10...last8for display.