Documentation
¶
Overview ¶
Package format handles message serialization using JSON frontmatter with Markdown body content. It provides message ID generation, parsing, and timestamp-based sorting utilities.
Index ¶
Constants ¶
View Source
const ( CurrentSchema = 1 CurrentVersion = 1 )
Schema and version constants.
Variables ¶
View Source
var ( ErrMissingFrontmatterStart = errors.New("missing frontmatter start") ErrMissingFrontmatterEnd = errors.New("missing frontmatter end") )
Sentinel errors for message parsing.
Functions ¶
func SortByTimestamp ¶
func SortByTimestamp[T Timestamped](items []T)
SortByTimestamp sorts a slice of Timestamped items by time, then by ID for stability.
Types ¶
type Header ¶
type Header struct {
Schema int `json:"schema"`
ID string `json:"id"`
From string `json:"from"`
To []string `json:"to"`
Thread string `json:"thread"`
Subject string `json:"subject,omitempty"`
Created string `json:"created"`
AckRequired bool `json:"ack_required"`
Refs []string `json:"refs,omitempty"`
}
Header is the JSON frontmatter stored at the top of each message file.
func ParseHeader ¶
func ReadHeaderFile ¶
type Message ¶
Message is the in-memory representation of a message file.
func ParseMessage ¶
func ReadMessageFile ¶
Click to show internal directories.
Click to hide internal directories.