pub struct Document {
pub source: String,
pub path: Option<PathBuf>,
pub title: Option<String>,
}Expand description
A Scrybe document — Markdown source with associated metadata.
Holds raw source text and a lazily-computed content digest
(BLAKE3 over the source bytes only — path and title are not hashed).
Rendering happens in scrybe-render (P1.3).
Fields§
§source: StringThe Markdown source text.
path: Option<PathBuf>Optional on-disk path. None for untitled / in-memory documents.
title: Option<String>Document title extracted from the first H1, if present.
Implementations§
Source§impl Document
impl Document
Sourcepub fn new(source: impl Into<String>) -> Self
pub fn new(source: impl Into<String>) -> Self
Creates a new in-memory document with the given source.
Sourcepub fn from_file(path: PathBuf, source: impl Into<String>) -> Self
pub fn from_file(path: PathBuf, source: impl Into<String>) -> Self
Creates a document from a file path and its source.
The title is populated automatically from the first H1 heading.
Sourcepub fn title_from_ast(&self) -> Option<String>
pub fn title_from_ast(&self) -> Option<String>
Returns the title extracted from the first H1 in the source, if any.
Sourcepub fn to_cbor(&self) -> Result<Vec<u8>, ScrybeError>
pub fn to_cbor(&self) -> Result<Vec<u8>, ScrybeError>
Serialises this document to deterministic CBOR bytes.
Sourcepub fn from_cbor(bytes: &[u8]) -> Result<Self, ScrybeError>
pub fn from_cbor(bytes: &[u8]) -> Result<Self, ScrybeError>
Deserialises a document from CBOR bytes.
Trait Implementations§
Source§impl ContentAddressable for Document
impl ContentAddressable for Document
Source§fn content_digest(&self) -> ContentDigest
fn content_digest(&self) -> ContentDigest
Digest of the raw Markdown source bytes. Path, title, and other metadata are deliberately excluded.
Source§fn content_id(&self) -> ContentDigest
fn content_id(&self) -> ContentDigest
renamed to content_digest: this is a BLAKE3 hex digest, not a CID
ContentAddressable::content_digest.