...

Package ordering

import "go.einride.tech/aip/ordering"
Overview
Index

Overview ▾

Package ordering provides primitives for implementing AIP ordering.

See: https://google.aip.dev/132#ordering (Standard methods: List > Ordering).

type Field

Field represents a single ordering field.

type Field struct {
    // Path is the path of the field, including subfields.
    Path string
    // Desc indicates if the ordering of the field is descending.
    Desc bool
}

func (Field) SubFields

func (f Field) SubFields() []string

SubFields returns the individual subfields of the field path, including the top-level subfield.

Subfields are specified with a . character, such as foo.bar or address.street.

type OrderBy

OrderBy represents an ordering directive.

type OrderBy struct {
    // Fields are the fields to order by.
    Fields []Field
}

func ParseOrderBy

func ParseOrderBy(r Request) (OrderBy, error)

ParseOrderBy request parses the ordering field for a Request.

func (*OrderBy) UnmarshalString

func (o *OrderBy) UnmarshalString(s string) error

UnmarshalString sets o from the provided ordering string. .

func (OrderBy) ValidateForMessage

func (o OrderBy) ValidateForMessage(m proto.Message) error

ValidateForMessage validates that the ordering paths are syntactically valid and refer to known fields in the specified message type.

func (OrderBy) ValidateForPaths

func (o OrderBy) ValidateForPaths(paths ...string) error

ValidateForPaths validates that the ordering paths are syntactically valid and refer to one of the provided paths.

type Request

Request is an interface for requests that support ordering.

See: https://google.aip.dev/132#ordering (Standard methods: List > Ordering).

type Request interface {
    // GetOrderBy returns the ordering of the request.
    GetOrderBy() string
}