Documentation ¶
Overview ¶
Package entities defines custom data types to be used across the whole application.
Index ¶
- Constants
- func CopyBytes(b []byte) (copiedBytes []byte)
- func FromHex(s string) ([]byte, error)
- func HasHexPrefix(str string) bool
- func HexToBytes(str string) ([]byte, error)
- func IsHex(str string) bool
- func IsHexCharacter(c byte) bool
- func IsHexInt256(input string) bool
- func IsInt256(s string) bool
- func LeftPadBytes(slice []byte, l int) []byte
- func MaxBigInt(x, y *big.Int) *big.Int
- func MinBigInt(x, y *big.Int) *big.Int
- func PowBigInt(a, b int64) *big.Int
- func RightPadBytes(slice []byte, l int) []byte
- func TrimRightZeroes(s []byte) []byte
- type ApplicationStandardID
- type ApplicationStandardResource
- type ApplicationStandardResourceMeta
- type ContextKey
- type HexBytes
- func (b *HexBytes) Bytes() []byte
- func (b HexBytes) Encode() string
- func (b HexBytes) MarshalJSON() ([]byte, error)
- func (b HexBytes) MarshalText() ([]byte, error)
- func (b HexBytes) String() string
- func (b *HexBytes) UnmarshalJSON(input []byte) error
- func (b *HexBytes) UnmarshalText(input []byte) error
- type HexBytes32
- func (b HexBytes32) Bytes() []byte
- func (b HexBytes32) Encode() string
- func (b *HexBytes32) FromBytes(src []byte)
- func (b *HexBytes32) FromString(src string)
- func (b HexBytes32) MarshalJSON() ([]byte, error)
- func (b HexBytes32) String() string
- func (b *HexBytes32) UnmarshalJSON(input []byte) error
- func (b *HexBytes32) UnmarshalText(input []byte) error
- type HexInt256
- type HexUInt64
- type Int256
- func (b *Int256) BigEndianByteAt(n int) byte
- func (b *Int256) BigInt() *big.Int
- func (b *Int256) ByteAt(padLength, n int) byte
- func (b *Int256) FirstBitSet() int
- func (b Int256) MarshalJSON() ([]byte, error)
- func (b *Int256) PaddedBytes(n int) []byte
- func (b *Int256) ReadBits(buf []byte)
- func (b *Int256) S256() *big.Int
- func (b *Int256) U256() *big.Int
- func (b *Int256) U256Bytes() []byte
- type InternalResourceID
- type StandardCollectionPage
- type StandardID
- type StandardResource
- type StandardResourceMeta
- type Timestamps
- type UInt64
Constants ¶
const ( OrderAsc = "asc" OrderDesc = "desc" OrderByLastUpdate = "lastUpdate" OrderByCreationDate = "creationDate" )
const MaxUInt64 = 1<<64 - 1
Variables ¶
This section is empty.
Functions ¶
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s which may be prefixed with "0x".
func HasHexPrefix ¶
HasHexPrefix validates str begins with '0x' or '0X'.
func HexToBytes ¶
HexToBytes returns the bytes represented by the hexadecimal string str.
func IsHexCharacter ¶
IsHexCharacter returns bool of c being a valid hexadecimal.
func IsHexInt256 ¶
IsHexInt256 checks if the input string is an hex encoded 256-bit integer
func IsInt256 ¶
IsInt256 parses the input string s as a 256-bit integer. It returns true if valid and false otherwise.
func LeftPadBytes ¶
LeftPadBytes zero-pads slice to the left up to length l.
func RightPadBytes ¶
RightPadBytes zero-pads slice to the right up to length l.
func TrimRightZeroes ¶
TrimRightZeroes returns a subslice of s without trailing zeroes
Types ¶
type ApplicationStandardID ¶
type ApplicationStandardID struct { ID string `json:"id" valid:"required,maxstringlength(64)" storage:"id"` ApplicationID string `json:"application_id" valid:"required" storage:"application_id"` }
ApplicationStandardID the Standard identification for every application-related resource.
type ApplicationStandardResource ¶
type ApplicationStandardResource struct { // ApplicationStandardID identifier of ApplicationStandardResource object ApplicationStandardID `json:",inline"` // Timestamps of ApplicationStandardResource object Timestamps `json:",inline"` }
ApplicationStandardResource the Standard identification for every application-related resource including when it was created and last updated
type ApplicationStandardResourceMeta ¶
type ApplicationStandardResourceMeta struct { // entities.ApplicationStandardResource standard application resource data ApplicationStandardResource // ResourceVersion resource version for resource locking ResourceVersion string `json:"ResourceVersion" storage:"resource_version"` }
ApplicationStandardResourceMeta defines the meta-information of an application resource.
type ContextKey ¶
type ContextKey string
ContextKey used in the signare for storing and retrieving values from context.
type HexBytes ¶
type HexBytes []byte
HexBytes marshals/unmarshals with 0x prefix. The empty slice marshals as 0x.
func HashKeccak256 ¶
HashKeccak256 returns the keccak256 hash of the input data
func NewHexBytes ¶
NewHexBytes wraps the given input as a HexBytes.
func NewHexBytesFromString ¶
NewHexBytesFromString decodes a hex string with 0x prefix.
func (HexBytes) MarshalJSON ¶
MarshalJSON implements the json.Marshaler.
func (HexBytes) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*HexBytes) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*HexBytes) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type HexBytes32 ¶
type HexBytes32 [32]byte
HexBytes32 holds the internal representation for HexBytes32
func NewHexBytes32FromString ¶
func NewHexBytes32FromString(input string) (HexBytes32, error)
NewHexBytes32FromString decodes a hex string with 0x prefix.
func (HexBytes32) Bytes ¶
func (b HexBytes32) Bytes() []byte
Bytes exports HexBytes32 as a slice of bytes.
func (HexBytes32) Encode ¶
func (b HexBytes32) Encode() string
Encode encodes b as a hex string with 0x prefix.
func (*HexBytes32) FromBytes ¶
func (b *HexBytes32) FromBytes(src []byte)
FromBytes transform a slice of bytes into a HexBytes32.
func (*HexBytes32) FromString ¶
func (b *HexBytes32) FromString(src string)
FromString transform a string into a HexBytes32.
func (HexBytes32) MarshalJSON ¶
func (b HexBytes32) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler.
func (*HexBytes32) UnmarshalJSON ¶
func (b *HexBytes32) UnmarshalJSON(input []byte) error
UnmarshalJSON implements json.Unmarshaler.
func (*HexBytes32) UnmarshalText ¶
func (b *HexBytes32) UnmarshalText(input []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
type HexInt256 ¶
type HexInt256 struct {
Int256
}
HexInt256 as an hex encoded 256-bit integer.
func NewHexInt256 ¶
NewHexInt256 returns a hex 256-bit integer from the input big integer
func NewHexInt256FromString ¶
NewHexInt256FromString decodes a hex string and returns a new 256-bit integer. Numbers larger than 256-bits are not allowed.
func (*HexInt256) Encode ¶
Encode encodes bigint as a hex string with 0x prefix. The sign of the integer is ignored.
func (*HexInt256) MarshalJSON ¶
MarshalJSON implements the json.Marshaler.
func (HexInt256) MarshalText ¶
MarshalText implements encoding.TextMarshaler
func (*HexInt256) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*HexInt256) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler
type HexUInt64 ¶
type HexUInt64 struct {
UInt64
}
HexUInt64 as an hex encoded 64 bit unsigned integer
func NewHexUInt64 ¶
NewHexUInt64 wraps the given input as a HexUInt64.
func NewHexUInt64FromString ¶
NewHexUInt64FromString decodes a hex string with 0x prefix and returns it as a HexUInt64.
func (*HexUInt64) MarshalJSON ¶
MarshalJSON implements the json.Marshaler.
func (HexUInt64) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*HexUInt64) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*HexUInt64) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Int256 ¶
Int256 as a 256-bit integer
func NewInt256FromInt ¶
NewInt256FromInt creates a new 256-bit integer from a 64 bit input integer
func NewInt256FromString ¶
NewInt256FromString parses the input string s as a 256-bit integer in decimal or hexadecimal syntax. Leading zeros are allowed. The empty string parses as zero.
func (*Int256) BigEndianByteAt ¶
BigEndianByteAt returns the byte at position n, in big-endian encoding, so that n==0 returns the least significant byte.
func (*Int256) ByteAt ¶
ByteAt returns the byte at position n, with the supplied pad length in little-endian encoding.
func (*Int256) FirstBitSet ¶
FirstBitSet returns the index of the first 1 bit in v, counting from LSB.
func (Int256) MarshalJSON ¶
MarshalJSON implements the json.Marshaler.
func (*Int256) PaddedBytes ¶
PaddedBytes encodes a big integer as a big-endian byte slice. The length of the slice is at least n bytes.
func (*Int256) S256 ¶
S256 interprets b as a two's complement number. S256(0) = 0, S256(1) = 1, S256(2**255) = -2**255, S256(2**256-1) = -1.
type InternalResourceID ¶
type InternalResourceID string
InternalResourceID is a hash composed by the unique keys of a resource, and it uniquely identifies a resource by a single ID.
func NewInternalResourceID ¶
func NewInternalResourceID() InternalResourceID
func (InternalResourceID) String ¶
func (i InternalResourceID) String() string
String implements fmt.Stringer
type StandardCollectionPage ¶
type StandardCollectionPage struct { // Limit of entries contained in the page Limit int `json:"limit"` // Offset zero-based offset of the first item in the page Offset int `json:"offset"` // MoreItems is true if there are entries after the < Offset + Size > entry MoreItems bool `json:"moreItems"` }
StandardCollectionPage defines the standard data structure included in all the collections items.
func NewUnlimitedQueryStandardCollectionPage ¶
func NewUnlimitedQueryStandardCollectionPage(size int) StandardCollectionPage
type StandardID ¶
type StandardID struct {
ID string `json:"id" valid:"required,maxstringlength(64)" storage:"id"`
}
StandardID the Standard identification for every not application-related resource.
type StandardResource ¶
type StandardResource struct { // StandardID identifier of StandardResource object StandardID `json:",inline"` // Timestamps of StandardResource object Timestamps `json:",inline"` }
StandardResource the Standard identification for every not application-related resource including when it was created and last updated
type StandardResourceMeta ¶
type StandardResourceMeta struct { // entities.StandardResource standard resource data StandardResource // ResourceVersion resource version for resource locking ResourceVersion string `json:"ResourceVersion" storage:"resource_version"` }
StandardResourceMeta defines the meta-information of a standard non-application resource.
type Timestamps ¶
type UInt64 ¶
type UInt64 uint64
UInt64 as an unsigned 64 bit integer
func NewUInt64FromString ¶
NewUInt64FromString parses s as an integer in decimal or hexadecimal syntax. Leading zeros are accepted. The empty string parses as zero.