1package boards23import "strconv"45type (6 // Role defines the type for user roles.7 Role string89 // Args is a list of generic arguments.10 Args []interface{}1112 // User contains user info.13 User struct {14 Address address15 Roles []Role16 }1718 // UsersIterFn defines a function type to iterate users.19 UsersIterFn func(User) bool2021 // Permissions define an interface to for permissioned execution.22 Permissions interface {23 // HasRole checks if a user has a specific role assigned.24 HasRole(address, Role) bool2526 // HasPermission checks if a user has a specific permission.27 HasPermission(address, Permission) bool2829 // WithPermission calls a callback when a user has a specific permission.30 // It panics on error.31 //32 // An inline crossing function call can be used by the implementation if33 // crossing is required to update its internal state, for example to create34 // proposals that when approved execute the callback:35 //36 // func(realm) {37 // // Update internal realm state38 // // ...39 // }(cross)40 WithPermission(address, Permission, Args, func())4142 // SetUserRoles adds a new user when it doesn't exist and sets its roles.43 // Method can also be called to change the roles of an existing user.44 // It panics on error.45 SetUserRoles(address, ...Role)4647 // RemoveUser removes a user from the permissioner.48 // It panics on error.49 RemoveUser(address) (removed bool)5051 // HasUser checks if a user exists.52 HasUser(address) bool5354 // UsersCount returns the total number of users the permissioner contains.55 UsersCount() int5657 // IterateUsers iterates permissions' users.58 IterateUsers(start, count int, fn UsersIterFn) bool59 }60)6162// Permission defines the type for permissions.63type Permission uint166465// String returns the string representation of a permission value.66func (p Permission) String() string {67 return strconv.FormatUint(uint64(p), 10)68}69Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.