Documentation ¶
Overview ¶
Package goahead provides ACL inspired permissions
Index ¶
- Variables
- type PermissionSet
- func (p *PermissionSet) All(indices ...uint) bool
- func (p *PermissionSet) Any(indices ...uint) bool
- func (p *PermissionSet) BitString() string
- func (p *PermissionSet) Bytes(indices ...uint) []uint64
- func (p *PermissionSet) Child(index uint) *PermissionSet
- func (p *PermissionSet) Clear(indices ...uint) *PermissionSet
- func (p *PermissionSet) Has(index uint) bool
- func (p *PermissionSet) HasMultiple(sets ...map[uint][]uint) map[uint][]bool
- func (p *PermissionSet) InPlaceIntersection(other *PermissionSet) *PermissionSet
- func (p *PermissionSet) IsEmpty() bool
- func (p *PermissionSet) Len() uint
- func (p *PermissionSet) MarshalBinary() ([]byte, error)
- func (p *PermissionSet) MarshalJSON() ([]byte, error)
- func (p *PermissionSet) Set(indices ...uint) *PermissionSet
- func (p *PermissionSet) Union(other *PermissionSet) *PermissionSet
- func (p *PermissionSet) UnmarshalBinary(data []byte) error
- func (p *PermissionSet) Walk(indices ...uint) bool
Constants ¶
This section is empty.
Variables ¶
var ( ErrBufTooSmall = errors.New("Binary buffer is too small") ErrBufOveflow = errors.New("64 bit overflow detected") )
Functions ¶
This section is empty.
Types ¶
type PermissionSet ¶
type PermissionSet struct { ID uint64 // contains filtered or unexported fields }
PermissionSet represents a group of permissions where each set bit grants permission
func UnmarshalJSON ¶
func UnmarshalJSON(data []byte) (*PermissionSet, error)
func (*PermissionSet) All ¶
func (p *PermissionSet) All(indices ...uint) bool
All returns true iff all bits are set
func (*PermissionSet) Any ¶
func (p *PermissionSet) Any(indices ...uint) bool
Any returns true if any index is set
func (*PermissionSet) BitString ¶
func (p *PermissionSet) BitString() string
func (*PermissionSet) Bytes ¶
func (p *PermissionSet) Bytes(indices ...uint) []uint64
Bytes returns the underling storage. The indices correspond to walking through the children.
func (*PermissionSet) Child ¶
func (p *PermissionSet) Child(index uint) *PermissionSet
Child eturns the child set for that index. If the Child does not exists a new set will be created of length 0
func (*PermissionSet) Clear ¶
func (p *PermissionSet) Clear(indices ...uint) *PermissionSet
func (*PermissionSet) Has ¶
func (p *PermissionSet) Has(index uint) bool
Has returns if bit at index is 1
func (*PermissionSet) HasMultiple ¶
func (p *PermissionSet) HasMultiple(sets ...map[uint][]uint) map[uint][]bool
HasMultiple checks the sets of permissions and upto 1 child group
func (*PermissionSet) InPlaceIntersection ¶
func (p *PermissionSet) InPlaceIntersection(other *PermissionSet) *PermissionSet
func (*PermissionSet) IsEmpty ¶
func (p *PermissionSet) IsEmpty() bool
IsEmpty returns true if no bits are set
func (*PermissionSet) Len ¶
func (p *PermissionSet) Len() uint
func (*PermissionSet) MarshalBinary ¶
func (p *PermissionSet) MarshalBinary() ([]byte, error)
func (*PermissionSet) MarshalJSON ¶
func (p *PermissionSet) MarshalJSON() ([]byte, error)
func (*PermissionSet) Set ¶
func (p *PermissionSet) Set(indices ...uint) *PermissionSet
Set sets the underlying bits to 1 for the specified indices
func (*PermissionSet) Union ¶
func (p *PermissionSet) Union(other *PermissionSet) *PermissionSet
Union is the equivalent of the |= other
func (*PermissionSet) UnmarshalBinary ¶
func (p *PermissionSet) UnmarshalBinary(data []byte) error
func (*PermissionSet) Walk ¶
func (p *PermissionSet) Walk(indices ...uint) bool
Walk checks that the all permissions at the indices are 1 where each index is for a level. If the level does not exist and the parent was 1 the result is true