types

package
v0.0.0-...-239b6c0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GroupNode NodeType = iota
	ObjectNode
	UserNode
	TribeNode

	NodeTypes int = 4
)

Each NodeType is an independent ID namespace

Variables

This section is empty.

Functions

func ErrInvalidPath

func ErrInvalidPath(s string) error

func ErrInvalidValue

func ErrInvalidValue(v interface{}) error

func GroupIdFromPath

func GroupIdFromPath(s string) (string, error)

GroupIdFromPath() attempts to extract the group Id from a URL.Path

func GroupIdFromURL

func GroupIdFromURL(s string) (string, error)

GroupIdFromURL() attempts to extract the group Id from a URL

func UsernameFromPath

func UsernameFromPath(s string) (string, error)

UsernameFromPath() attempts to extract the username from a URL.Path

func UsernameFromURL

func UsernameFromURL(s string) (string, error)

UsernameFromURL() attempts to extract the username from a URL

Types

type Group

type Group struct {
	NextGroupObjectsUpdate time.Time `json:"-"`

	Objects []*Object `json:",omitempty"`
	Groups  []*Group  `json:",omitempty"`
	// contains filtered or unexported fields
}

func NewGroup

func NewGroup(id, name string) *Group

Creates dummy Group, disconnected from the library

func (*Group) AddGroup

func (g *Group) AddGroup(sg *Group, merge bool) (*Group, error)

func (*Group) AddNode

func (g *Group) AddNode(sg Node, merge bool) (Node, error)

func (*Group) GetObjectsURL

func (g *Group) GetObjectsURL() string

func (*Group) GroupsAll

func (g *Group) GroupsAll() []*Group

func (*Group) HasNodes

func (g *Group) HasNodes() bool

func (*Group) Id

func (g *Group) Id() string

func (*Group) Library

func (e *Group) Library() *Library

func (*Group) Lock

func (e *Group) Lock() bool

func (*Group) Name

func (g *Group) Name() string

func (*Group) Nodes

func (g *Group) Nodes() []Node

func (*Group) OnError

func (e *Group) OnError(g Node, err error)

func (*Group) OnNewNode

func (e *Group) OnNewNode(g Node)

func (*Group) OnNodeUpdate

func (e *Group) OnNodeUpdate(g Node, field string, before, after interface{})

func (*Group) Parent

func (g *Group) Parent() Node

func (*Group) Path

func (g *Group) Path() string

func (*Group) SetName

func (g *Group) SetName(name string)

func (*Group) Type

func (g *Group) Type() NodeType

func (*Group) Unlock

func (e *Group) Unlock()

func (*Group) User

func (g *Group) User() *User

type Grouper

type Grouper interface {
	Node

	AddGroup(*Group, bool) (*Group, error)
}

type Id

type Id struct {
	// contains filtered or unexported fields
}

func NewId

func NewId(v interface{}) (Id, error)

func (*Id) Int

func (w *Id) Int() (int, bool)

func (Id) Lt

func (a Id) Lt(b Id) bool

func (Id) MarshalJSON

func (w Id) MarshalJSON() ([]byte, error)

func (Id) MarshalYAML

func (w Id) MarshalYAML() (interface{}, error)

func (*Id) Ok

func (w *Id) Ok() bool

func (*Id) SetFromString

func (w *Id) SetFromString(s string) bool

func (*Id) SetInt

func (w *Id) SetInt(n int) bool

func (*Id) SetString

func (w *Id) SetString(s string) bool

func (*Id) String

func (w *Id) String() string

func (*Id) UnmarshalJSON

func (w *Id) UnmarshalJSON(data []byte) error

func (*Id) UnmarshalYAML

func (w *Id) UnmarshalYAML(unmarshal func(interface{}) error) error

func (*Id) Value

func (w *Id) Value() (interface{}, bool)

type Library

type Library struct {
	// contains filtered or unexported fields
}

func (*Library) AddUser

func (w *Library) AddUser(u *User, merge bool) (*User, error)

func (*Library) GetGroup

func (w *Library) GetGroup(id string) (*Group, error)

func (*Library) GetUser

func (w *Library) GetUser(user string) (*User, error)

func (*Library) Groups

func (w *Library) Groups() []string

Groups() returns slice of registered IDs

func (*Library) Keys

func (w *Library) Keys(typ NodeType) []string

Keys() returns slice of keys of a given type

func (*Library) OnError

func (w *Library) OnError(g Node, err error)

func (*Library) OnNewNode

func (w *Library) OnNewNode(g Node)

func (*Library) OnNodeUpdate

func (w *Library) OnNodeUpdate(g Node, field string, before, after interface{})

func (*Library) SetEvents

func (w *Library) SetEvents(ev LibraryEvents)

func (*Library) Users

func (w *Library) Users() []string

Users() returns slice of registered usernames

type LibraryEvents

type LibraryEvents struct {
	OnNewNode    func(w *Library, g Node)
	OnNodeUpdate func(w *Library, g Node, field string, before, after interface{})
	OnError      func(w *Library, g Node, err error)
}

type Node

type Node interface {
	Id() string
	Name() string
	Type() NodeType
	Path() string

	Library() *Library
	User() *User
	Parent() Node

	AddNode(Node, bool) (Node, error)
	HasNodes() bool
	Nodes() []Node
}

type NodeType

type NodeType int

func (NodeType) String

func (t NodeType) String() string

type Object

type Object struct{}

type Store

type Store interface {
	Load() (*Library, error)
	Store(*Library) error
}

type Tribe

type Tribe struct {
	Avatar string

	Groups []*Group
	// contains filtered or unexported fields
}

func NewTribe

func NewTribe(id, name string) *Tribe

func (*Tribe) AddGroup

func (g *Tribe) AddGroup(sg *Group, merge bool) (*Group, error)

func (*Tribe) AddNode

func (g *Tribe) AddNode(sg Node, merge bool) (Node, error)

func (*Tribe) GroupsAll

func (g *Tribe) GroupsAll() []*Group

func (*Tribe) HasNodes

func (g *Tribe) HasNodes() bool

func (*Tribe) Id

func (g *Tribe) Id() string

func (*Tribe) Library

func (e *Tribe) Library() *Library

func (*Tribe) Lock

func (e *Tribe) Lock() bool

func (*Tribe) Name

func (g *Tribe) Name() string

func (*Tribe) Nodes

func (g *Tribe) Nodes() []Node

func (*Tribe) OnError

func (e *Tribe) OnError(g Node, err error)

func (*Tribe) OnNewNode

func (e *Tribe) OnNewNode(g Node)

func (*Tribe) OnNodeUpdate

func (e *Tribe) OnNodeUpdate(g Node, field string, before, after interface{})

func (*Tribe) Parent

func (g *Tribe) Parent() Node

func (*Tribe) Path

func (g *Tribe) Path() string

func (*Tribe) Type

func (g *Tribe) Type() NodeType

func (*Tribe) Unlock

func (e *Tribe) Unlock()

func (*Tribe) User

func (g *Tribe) User() *User

type User

type User struct {
	NextUserSharedLibraryUpdate time.Time `json:"-"`

	Avatar string   `json:",omitempty"`
	Groups []*Group `json:",omitempty"`
	Tribes []*Tribe `json:",omitempty"`
	// contains filtered or unexported fields
}

func NewUser

func NewUser(username, name string) *User

func (*User) AddGroup

func (u *User) AddGroup(g *Group, merge bool) (*Group, error)

func (*User) AddNode

func (u *User) AddNode(g Node, merge bool) (Node, error)

func (*User) AddTribe

func (u *User) AddTribe(g *Tribe, merge bool) (*Tribe, error)

func (*User) GetSharedGroupsURL

func (u *User) GetSharedGroupsURL() string

func (*User) GroupsAll

func (u *User) GroupsAll() []*Group

func (*User) HasNodes

func (u *User) HasNodes() bool

func (*User) Id

func (u *User) Id() string

func (*User) Library

func (e *User) Library() *Library

func (*User) Lock

func (e *User) Lock() bool

func (*User) Name

func (u *User) Name() string

func (*User) Nodes

func (u *User) Nodes() []Node

func (*User) OnError

func (e *User) OnError(g Node, err error)

func (*User) OnNewNode

func (e *User) OnNewNode(g Node)

func (*User) OnNodeUpdate

func (e *User) OnNodeUpdate(g Node, field string, before, after interface{})

func (*User) Parent

func (u *User) Parent() Node

func (*User) Path

func (u *User) Path() string

func (*User) SetName

func (u *User) SetName(name string)

func (*User) Type

func (u *User) Type() NodeType

func (*User) Unlock

func (e *User) Unlock()

func (*User) User

func (u *User) User() *User

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL