Help us shape the future of Go! Take the 2026 Go Developer Survey

codecs

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package codecs maps domain entities to managed AsciiDoc documents. Typed codecs validate headers and domain values, keeping body bytes verbatim. RawNoteCodec additionally checks complete document syntax before raw saves.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Identify

func Identify(source []byte) (uuid.UUID, ports.NoteKind, error)

Identify reads the identity and kind used to select a document's codec. Specific domain properties are validated by that codec's Decode method.

Types

type BookmarkCodec

type BookmarkCodec struct{}

BookmarkCodec encodes managed headers and decodes validated bookmark entities.

func (BookmarkCodec) Decode

func (BookmarkCodec) Decode(source []byte) (*bookmarks.Bookmark, error)

Decode validates the bookmark header and domain values while keeping the body verbatim. It does not validate the body's AsciiDoc syntax.

func (BookmarkCodec) Encode

func (BookmarkCodec) Encode(entity *bookmarks.Bookmark) ([]byte, error)

Encode renders managed attributes and the entity body; unrelated source formatting is not retained.

type HabitCodec

type HabitCodec struct{}

HabitCodec encodes managed headers and decodes validated habit entities.

func (HabitCodec) Decode

func (HabitCodec) Decode(source []byte) (*habits.Habit, error)

Decode validates the habit header and domain values while keeping the body verbatim. It does not validate the body's AsciiDoc syntax.

func (HabitCodec) Encode

func (HabitCodec) Encode(habit *habits.Habit) ([]byte, error)

Encode renders managed attributes and the entity body; unrelated source formatting is not retained.

type InboxCodec

type InboxCodec struct{}

InboxCodec encodes managed headers and decodes validated inbox entities.

func (InboxCodec) Decode

func (InboxCodec) Decode(source []byte) (*inbox.Inbox, error)

Decode validates the inbox header and domain values while keeping the body verbatim. It does not validate the body's AsciiDoc syntax.

func (InboxCodec) Encode

func (InboxCodec) Encode(entity *inbox.Inbox) ([]byte, error)

Encode renders managed attributes and the entity body; unrelated source formatting is not retained.

type JournalCodec

type JournalCodec struct{}

JournalCodec encodes managed headers and decodes validated journal entities.

func (JournalCodec) Decode

func (JournalCodec) Decode(source []byte) (*journals.Journal, error)

Decode validates the journal header and domain values while keeping the body verbatim. It does not validate the body's AsciiDoc syntax.

func (JournalCodec) Encode

func (JournalCodec) Encode(entity *journals.Journal) ([]byte, error)

Encode renders managed attributes and the entity body; unrelated source formatting is not retained.

type PageCodec

type PageCodec struct{}

PageCodec encodes managed headers and decodes validated page entities.

func (PageCodec) Decode

func (PageCodec) Decode(source []byte) (*pages.Page, error)

Decode validates the page header and domain values while keeping the body verbatim. It does not validate the body's AsciiDoc syntax.

func (PageCodec) Encode

func (PageCodec) Encode(entity *pages.Page) ([]byte, error)

Encode renders managed attributes and the entity body; unrelated source formatting is not retained.

type PersonCodec

type PersonCodec struct{}

PersonCodec encodes managed headers and decodes validated person entities.

func (PersonCodec) Decode

func (PersonCodec) Decode(source []byte) (*persons.Person, error)

Decode validates the person header and domain values while keeping the body verbatim. It does not validate the body's AsciiDoc syntax.

func (PersonCodec) Encode

func (PersonCodec) Encode(person *persons.Person) ([]byte, error)

Encode renders managed attributes and the entity body; unrelated source formatting is not retained.

type RawNoteCodec added in v0.4.0

type RawNoteCodec struct{}

RawNoteCodec uses the same domain codecs as the typed repositories.

func (RawNoteCodec) Decode added in v0.4.0

func (codec RawNoteCodec) Decode(kind ports.NoteKind, source []byte) (ports.RawNoteHeader, error)

Decode validates managed metadata, the supported AsciiDoc syntax and typed domain fields. An empty expected kind accepts any supported note type; diagnostics include line and column.

func (RawNoteCodec) Inspect added in v0.4.0

func (RawNoteCodec) Inspect(source []byte) (ports.RawNoteHeader, error)

Inspect deliberately parses only the header so invalid bodies can be repaired.

func (RawNoteCodec) Stamp added in v0.4.0

func (RawNoteCodec) Stamp(source []byte, at time.Time) ([]byte, error)

Stamp replaces the value span of the effective header declaration. Everything outside that span, including line endings and body attributes, is unchanged.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL