Documentation
¶
Overview ¶
Package r3toml provides bidirectional conversion between r3 query types and TOML.
Category: Serialization dialect.
It serializes r3.Filters, r3.Sorts, r3.PaginationSpec, and r3.Fields to TOML for configuration files, and parses them back. Like the YAML dialect, the TOML dialect uses human-readable names (field/operator/value).
Limitation: TOML has no null type. Filters with nil values (IS NULL checks) cannot be encoded to TOML. FilterToTOML returns an error for such filters.
Index ¶
- Variables
- func IsErrDialectorFailure(err error) bool
- func TOMLToField(tf TOMLField) *r3.FieldSpec
- func TOMLToFilter(tf *TOMLFilter) (*r3.FilterSpec, error)
- func TOMLToFilters(tfs TOMLFilters) (r3.Filters, error)
- func TOMLToPagination(tp *TOMLPagination) (*r3.PaginationSpec, error)
- func TOMLToSort(ts *TOMLSort) (*r3.SortSpec, error)
- type TOMLCursorPagination
- type TOMLField
- type TOMLFields
- type TOMLFilter
- type TOMLFilters
- type TOMLPagination
- type TOMLSort
Constants ¶
This section is empty.
Variables ¶
var ErrTOMLDialectorFailed = errors.New("toml dialector failed")
ErrTOMLDialectorFailed is a generic error for r3toml dialector failures.
var ErrTOMLNullValue = errors.New("TOML does not support null values")
ErrTOMLNullValue is returned when trying to encode a nil value to TOML, which does not support null.
Functions ¶
func IsErrDialectorFailure ¶
IsErrDialectorFailure checks if the given error is a r3toml failure.
func TOMLToField ¶
TOMLToField converts a TOMLField to a FieldSpec.
func TOMLToFilter ¶
func TOMLToFilter(tf *TOMLFilter) (*r3.FilterSpec, error)
TOMLToFilter converts a TOMLFilter to a FilterSpec.
func TOMLToFilters ¶
func TOMLToFilters(tfs TOMLFilters) (r3.Filters, error)
TOMLToFilters converts a slice of TOMLFilters to r3.Filters.
func TOMLToPagination ¶
func TOMLToPagination(tp *TOMLPagination) (*r3.PaginationSpec, error)
TOMLToPagination converts a TOMLPagination to a PaginationSpec.
Types ¶
type TOMLCursorPagination ¶
type TOMLCursorPagination struct {
After string `toml:"after,omitempty"`
Before string `toml:"before,omitempty"`
Limit int `toml:"limit,omitempty"`
}
TOMLCursorPagination represents cursor-based pagination in TOML format.
func (*TOMLCursorPagination) ToCursorSpec ¶
func (tc *TOMLCursorPagination) ToCursorSpec() *r3.CursorSpec
ToCursorSpec converts TOMLCursorPagination to an r3.CursorSpec. Returns nil if no cursor parameters are set.
type TOMLField ¶
type TOMLField string
TOMLField is a string value representing a field name in TOML.
func FieldToTOML ¶
FieldToTOML converts a FieldSpec to a TOMLField.
type TOMLFilter ¶
type TOMLFilter struct {
Field string `toml:"field,omitempty"`
Operator string `toml:"operator,omitempty"` // canonical: "eq", "gt", etc.
Value any `toml:"value,omitempty"`
And []*TOMLFilter `toml:"and,omitempty"`
Or []*TOMLFilter `toml:"or,omitempty"`
}
TOMLFilter represents a filter criteria in TOML format. Uses human-readable field names (field/operator/value) for configuration files.
func FilterToTOML ¶
func FilterToTOML(f *r3.FilterSpec) (*TOMLFilter, error)
FilterToTOML converts a FilterSpec to a TOMLFilter. Returns ErrTOMLNullValue if the filter has a nil value, since TOML has no null type.
func (*TOMLFilter) ToFilterSpec ¶
func (tf *TOMLFilter) ToFilterSpec() (*r3.FilterSpec, error)
ToFilterSpec converts a TOMLFilter to an r3.FilterSpec.
type TOMLPagination ¶
type TOMLPagination struct {
PageNum int `toml:"page_num,omitempty"`
PageSize int `toml:"page_size,omitempty"`
}
TOMLPagination represents pagination in TOML format.
func PaginationToTOML ¶
func PaginationToTOML(p *r3.PaginationSpec) *TOMLPagination
PaginationToTOML converts a PaginationSpec to a TOMLPagination.
func (*TOMLPagination) ToPaginationSpec ¶
func (tp *TOMLPagination) ToPaginationSpec() (*r3.PaginationSpec, error)
ToPaginationSpec converts a TOMLPagination to an r3.PaginationSpec.