Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Compare ¶ added in v1.18.0
type Compare[K comparable] interface { // IsEqual checks if two strings are equal. // // It takes two strings as parameters and returns true if the strings are equal, // false otherwise. // // If either of the strings passed as parameters are empty or nil, the method // will return false. IsEqual(ref, part K) bool // IsContains checks if a given string is contained in another. // // It takes two strings as parameters and returns true if the first string // is contained in the second, false otherwise. // // If the first string passed as parameter is empty or nil, the method will // return false. IsContains(ref, part K) bool // IsEmpty checks if a given string is empty. // // It takes a string as parameter and returns true if the string is empty, // false otherwise. // // If the string passed as parameter is nil, the method will return false. IsEmpty(part K) bool }
func NewCompare ¶ added in v1.18.0
func NewCompare[K comparable](eq CompareEqual[K], cn CompareContains[K], em CompareEmpty[K]) Compare[K]
NewCompare creates a new Compare object.
It takes three functions as parameters: - eq, which checks if two strings are equal. - cn, which checks if a string contains another. - em, which checks if a string is empty.
It returns a Compare object which can be used to compare strings.
If any of the functions passed as parameters are nil, the corresponding Compare method will return false.
type CompareContains ¶ added in v1.18.0
type CompareContains[K comparable] func(ref, part K) bool
type CompareEmpty ¶ added in v1.18.0
type CompareEmpty[K comparable] func(part K) bool
type CompareEqual ¶ added in v1.18.0
type CompareEqual[K comparable] func(ref, part K) bool
type FctWalk ¶
type FctWalk[K comparable, M any] func(key K, model M) bool
type KVDriver ¶
type KVDriver[K comparable, M any] interface { // New returns a new instance of the KVDriver interface. // The function takes no parameter and returns a new instance of the interface. // The returned instance is not initialized and needs to be initialized before use. New() KVDriver[K, M] // Get retrieves the value associated with the given key. // The function will return nil if the key does not exist. // If an error occurs during the retrieval, it will be returned. // The iteration order is not defined. // If no key is found, the function will return nil. Get(key K, model *M) error // Set sets the value associated with the given key. // If an error occurs during the setting, it will be returned. // The iteration order is not defined. // If no key is found, the function will return an error. Set(key K, model M) error // Del deletes the key-value pair associated with the given key. // If the key does not exist, the function will return nil. // If an error occurs during the deletion, it will be returned. // The iteration order is not defined. Del(key K) error // List returns a list of all keys in the driver. // The function will return an error if it occurs during the iteration. // The iteration order is not defined. // If no key is found, the function will return an empty list. List() ([]K, error) // Search returns a list of keys that match the given pattern. // The function will return an error if it occurs during the iteration. // The iteration order is not defined. // If no key matches the pattern, the function will return an empty list. Search(pattern K) ([]K, error) // Walk will call the given function for each key-value pair in the driver. // The function will be called with the key and the value associated with the key. // If the function returns false, the iteration will stop. // If an error occurs during the iteration, it will be returned. // The iteration order is not defined. Walk(fct FctWalk[K, M]) error }
type KVItem ¶
type KVItem[K comparable, M any] interface { // Set sets the value of the item to the given model. Set(model M) // Get returns the current value of the item. Get() M // Key returns the key associated with the item. This key is used to identify // the item in the storage. Key() K // Load loads the item from the storage. It returns an error if the item // cannot be loaded. Load() error // Store saves the item to the storage. If force is true, the item is saved even // if the item has not changed since it was last loaded or stored. If force is // false, the item is only saved if it has changed since it was last loaded or // stored. It returns an error if the item cannot be stored. Store(force bool) error // Remove removes the item from the storage. It returns an error if the item // has not been loaded or if the item cannot be removed. Remove() error // Clean resets the item to its initial state. This is useful when the item // is re-used and the old state should be forgotten. Clean() // HasChange returns true if the current value of the item has changed since // it was last loaded or stored. HasChange() bool }
type KVTable ¶
type KVTable[K comparable, M any] interface { // Get returns the item associated with the given key. // If the key does not exist, the function will return nil and no error. // If an error occurs during the retrieval, it will be returned. // The iteration order is not defined. Get(key K) (KVItem[K, M], error) // Del deletes the item associated with the given key. // If the key does not exist, the function will return nil. // If an error occurs during the deletion, it will be returned. // The iteration order is not defined. Del(key K) error // List returns a list of all items in the table. // The function will return an error if it occurs during the iteration. // The iteration order is not defined. // If no item is found, the function will return an empty list. List() ([]KVItem[K, M], error) // Search returns a list of all items in the table that match the given pattern. // The function will return an error if it occurs during the iteration. // The iteration order is not defined. // If no item matches the pattern, the function will return an empty list. Search(pattern K) ([]KVItem[K, M], error) // Walk iterates over all items in the table and calls the provided function. // The function is called with the key and the value associated with the key. // If the function returns false, the iteration stops. // If the function returns an error, the iteration stops and the error is returned. // If no error occurs, the function returns nil. Walk(fct FuncWalk[K, M]) error }
Click to show internal directories.
Click to hide internal directories.