github.com/ddev/ddev@v1.23.2-0.20240519125000-d824ffe36ff3/pkg/config/state/types/state.go (about)

     1  package types
     2  
     3  type StateEntry = interface{}
     4  type StateEntryKey = string
     5  
     6  type State interface {
     7  	// Load reads the state from the storage into the memory.
     8  	Load() error
     9  
    10  	// Save writes the state from the memory into the storage.
    11  	Save() error
    12  
    13  	// Loaded returns true if the state is loaded into the memory.
    14  	Loaded() bool
    15  
    16  	// Changed returns true if the in-memory state has changed.
    17  	Changed() bool
    18  
    19  	// Get retrieves the state for the key into the state entry which must be
    20  	// provided as pointer see example.
    21  	//
    22  	// For example:
    23  	//
    24  	//     type T struct {
    25  	//         F int `yaml:"a,omitempty"`
    26  	//         B int
    27  	//     }
    28  	//     var t T
    29  	//     State.Get("my_key", &t)
    30  	//
    31  	Get(StateEntryKey, StateEntry) error
    32  
    33  	// Set updates the state entry for the key. The state entry must not be
    34  	// provided as pointer see example.
    35  	//
    36  	// For example:
    37  	//
    38  	//     type T struct {
    39  	//         F int `yaml:"a,omitempty"`
    40  	//         B int
    41  	//     }
    42  	//     var t T
    43  	//     State.Set("my_key", t)
    44  	//
    45  	Set(StateEntryKey, StateEntry) error
    46  }