Documentation
¶
Overview ¶
Package rules holds the small rules every thread.Storage backend must answer identically: the List limit, the metadata and title filters, the paging cursor, and the line discipline of a session's bytes. Memory and jsonl call these directly; a backend outside the thread module (sqlite) keeps its own copy, and the threadtest conformance table pins every copy to one answer.
The package imports nothing from thread — thread imports it — so the rules speak in plain values: maps, byte slices, times and ids.
Index ¶
- Constants
- func AfterCursor(created time.Time, id string, before time.Time, beforeID string) bool
- func CloneMeta(kv map[string]string) map[string]string
- func CompareNewestFirst(aCreated time.Time, aID string, bCreated time.Time, bID string) int
- func CompleteLen(b []byte) int
- func InfoTitle(line []byte) string
- func LimitOf(n int) int
- func MetaMatch(meta, want map[string]string) bool
- func SplitLines(b []byte) [][]byte
- func TitleMatches(title, search string) bool
- func TitleOf(lines [][]byte) string
- func Torn(b []byte) bool
Constants ¶
const ( DefaultLimit = 50 MaxLimit = 500 )
The List page bounds: a zero or negative Query.Limit reads as DefaultLimit, and anything above MaxLimit clamps to it.
Variables ¶
This section is empty.
Functions ¶
func AfterCursor ¶
AfterCursor reports whether a session (created, id) lies strictly after the paging cursor (before, beforeID) in List order — newest first by created, ties by id descending. A zero before is no cursor: everything is after it. With a cursor, a session qualifies when it was created strictly before the cursor's time, or at exactly that time with an id strictly below beforeID; an empty beforeID therefore admits nothing from the cursor's own instant.
func CloneMeta ¶
CloneMeta copies a metadata map so a header never aliases the caller's; an empty map clones to nil.
func CompareNewestFirst ¶
CompareNewestFirst orders two sessions for List: newest first by created, ties by id descending.
func CompleteLen ¶
CompleteLen returns the length of b's complete prefix: everything up to and including the last newline, 0 when b holds none. Truncating to it is the torn-tail repair.
func InfoTitle ¶
InfoTitle returns the title one entry line sets: non-empty only for an info entry that carries one.
func LimitOf ¶
LimitOf normalizes Query.Limit: zero and negatives mean DefaultLimit, values above MaxLimit clamp.
func MetaMatch ¶
MetaMatch reports whether meta holds every pair of want, exactly: a wanted key must be present and carry the wanted value. An empty want matches everything.
func SplitLines ¶
SplitLines splits on '\n', complete lines only: the bytes after the last newline, if any, are a torn tail and are not returned. The lines alias b.
func TitleMatches ¶
TitleMatches reports whether the title contains the search as a substring, folding case.
Types ¶
This section is empty.