package storage import ( "galaxy/model/client" "galaxy/model/order" "galaxy/model/report" ) type Storage interface { UIStorage FileExists(string) (bool, error) ReadFile(string) ([]byte, error) WriteFile(string, []byte) error DeleteFile(string) error ListFiles() ([]string, error) } // UIStorage manages Client's data local storing and retrieval. // It performs all I/O operations asynchronously to avoid UI main thread blocking. type UIStorage interface { // StateExists check asynchronously for previously saved [model.State] exists on the filesystem. // Passed callback func will will accept false and non-nil error in case of I/O or decoding errors occuried, // otherwise bool parameter will indicate existence of previously stores state StateExists(func(bool, error)) // LoadState loads Client's [model.State] from filesystem data asynchronously. // Passed callback func will accept non-nil error in case of I/O or decoding errors occuried, // otherwise callback func accepts loaded [model.State]. LoadState(func(client.State, error)) // SaveState stores Client's state at the filesystem asynchronously. // I/O or encoding error may occur, it that case callback func will be called with non-nil error. SaveState(client.State, func(error)) // LoadReport loads a [report.Report] for a given [model.GameID] and turn number from filesystem asynchronously. // Passed callback func will will accept non-nil error in case of I/O or decoding errors occuried, // otherwise callback func accepts loaded [report.Report]. LoadReport(client.GameID, uint, func(report.Report, error)) // SaveReport stores given [report.Report] for a given [model.GameID] and turn number at the filesystem asynchronously. // I/O or encoding error may occur, it that case callback func will be called with non-nil error. SaveReport(client.GameID, uint, report.Report, func(error)) // LoadOrder loads a [order.Order] for a given [model.GameID] and turn number from filesystem asynchronously. // Passed callback func will will accept non-nil error in case of I/O or decoding errors occuried, // otherwise callback func accepts loaded [order.Order]. LoadOrder(client.GameID, uint, func(order.Order, error)) // SaveOrder stores given [order.Order] for a given [model.GameID] and turn number at the filesystem asynchronously. // I/O or encoding error may occur, it that case callback func will be called with non-nil error. SaveOrder(client.GameID, uint, order.Order, func(error)) }