Documentation ¶
Index ¶
- func Marshal(fm *FieldMask) ([]byte, error)
- type FieldMask
- func (self *FieldMask) All() bool
- func (self *FieldMask) Exist() bool
- func (self *FieldMask) Field(id int16) (*FieldMask, bool)
- func (self *FieldMask) ForEachChild(scanner func(strKey string, intKey int, child *FieldMask) bool)
- func (cur *FieldMask) GetPath(desc *thrift_reflection.TypeDescriptor, path string) (*FieldMask, bool)
- func (self *FieldMask) Int(id int) (*FieldMask, bool)
- func (self *FieldMask) IsBlack() bool
- func (fm *FieldMask) MarshalJSON() ([]byte, error)
- func (fm *FieldMask) PathInMask(desc *thrift_reflection.TypeDescriptor, path string) bool
- func (self *FieldMask) Str(id string) (*FieldMask, bool)
- func (self FieldMask) String(desc *thrift_reflection.TypeDescriptor) string
- func (self *FieldMask) TransferFrom(s *fieldMaskTransfer) error
- func (self *FieldMask) Type() FieldMaskType
- func (self *FieldMask) UnmarshalJSON(in []byte) error
- type FieldMaskType
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FieldMask ¶
type FieldMask struct {
// contains filtered or unexported fields
}
FieldMask represents a collection of thrift pathes See
func NewFieldMask ¶
func NewFieldMask(desc *thrift_reflection.TypeDescriptor, pathes ...string) (*FieldMask, error)
NewFieldMask create a new fieldmask
func Unmarshal ¶
Marshal deserializes a fieldmask from bytes.
Notice: This API uses cache to accelerate processing, at the cost of increasing memory usage
func (*FieldMask) Field ¶
Field returns the specific sub mask for a given id, and tells if the id in the mask
func (*FieldMask) ForEachChild ¶
ForEachChild iterates over underlying children of a FieldMask (if any). A child's key type depends on the type of the FieldMask:
- FtStruct | FtList | FtIntMap: intKey
- FtStrMap: strKey
func (*FieldMask) GetPath ¶
func (cur *FieldMask) GetPath(desc *thrift_reflection.TypeDescriptor, path string) (*FieldMask, bool)
getPathAncestor tells if a given path is in current fieldmask, and return the nearest settled ancestor (include itself)
func (*FieldMask) Int ¶
Int returns the specific sub mask for a given index, and tells if the index in the mask
func (*FieldMask) MarshalJSON ¶
MarshalJSON marshals the fieldmask into json.
For example:
- pathes `[]string{"$.Extra[0].List", "$.Extra[*].Set", "$.Meta.F2{0}", "$.Meta.F2{*}.Addr"}` will produces:
- `{"path":"$","type":"Struct","children":[{"path":6,"type":"List","children":[{"path":"*","type":"Struct","children":[{"path":4,"type":"List"}]}]},{"path":256,"type":"Struct","children":[{"path":2,"type":"IntMap","children":[{"path":"*","type":"Struct","children":[{"path":0,"type":"Scalar"}]}]}]}]}`
For details:
- `path` is the path segment of current fieldmask layer
- `type` is the `FieldMaskType` of the fieldmask -`children` is the chidlren of subsequent pathes
- each fieldmask always starts with root path "$"
- path "*" indicates all subsequent path of the fieldmask shares the same sub fieldmask
func (*FieldMask) PathInMask ¶
func (fm *FieldMask) PathInMask(desc *thrift_reflection.TypeDescriptor, path string) bool
PathInMask tells if a given path is already in current fieldmask
func (*FieldMask) Str ¶
Field returns the specific sub mask for a given string, and tells if the string in the mask
func (FieldMask) String ¶
func (self FieldMask) String(desc *thrift_reflection.TypeDescriptor) string
String pretty prints the structure a FieldMask represents
WARING: This is unstable API, the printer format is not guaranteed
func (*FieldMask) TransferFrom ¶
TransferFrom transfroms a FieldMaskTransfer to the FieldMask
func (*FieldMask) Type ¶
func (self *FieldMask) Type() FieldMaskType
Type tells its FieldMaskType, which is decided by the Thrift Path definition.
func (*FieldMask) UnmarshalJSON ¶
UnmarshalJSON unmarshal the fieldmask from json.
Input JSON **MUST** be according to the schema of `FieldMask.MarshalJSON()`
type FieldMaskType ¶
type FieldMaskType uint8
FieldMaskType indicates the corresponding thrift message type for a fieldmask
const ( // Invalid or unsupported thrift type FtInvalid FieldMaskType = iota // thrift scalar types, including BOOL/I8/I16/I32/I64/DOUBLE/STRING/BINARY, or neither-string-nor-integer-typed-key MAP FtScalar // thrift LIST/SET FtList // thrift STRUCT FtStruct // thrift MAP with string-typed key FtStrMap // thrift MAP with integer-typed key FtIntMap )
FieldMaskType Enums
func (FieldMaskType) MarshalText ¶
func (ft FieldMaskType) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler
func (*FieldMaskType) UnmarshalText ¶
func (ft *FieldMaskType) UnmarshalText(in []byte) error
UnmarshalText implements encoding.TextUnmarshaler
type Options ¶
type Options struct { // BlackListMode enables black-list mode when create FieldMask, // which means `Field()/Str()/Int()` will return false for a **Complete** Path in the FieldMask BlackListMode bool }
Options for creating FieldMask
func (Options) NewFieldMask ¶
func (opts Options) NewFieldMask(desc *thrift_reflection.TypeDescriptor, pathes ...string) (*FieldMask, error)
NewFieldMask create a new fieldmask with options