Alex Vanin
20de74a505
Due to source code relocation from GitHub. Signed-off-by: Alex Vanin <a.vanin@yadro.com>
32 lines
903 B
Go
32 lines
903 B
Go
package locodedb
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
locodecolumn "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/locode/column"
|
|
)
|
|
|
|
// LocationCode represents a location code for
|
|
// the storage in the FrostFS location database.
|
|
type LocationCode locodecolumn.LocationCode
|
|
|
|
// LocationCodeFromString parses a string UN/LOCODE location code
|
|
// and returns a LocationCode.
|
|
func LocationCodeFromString(s string) (*LocationCode, error) {
|
|
lc, err := locodecolumn.LocationCodeFromString(s)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("could not parse location code: %w", err)
|
|
}
|
|
|
|
return LocationFromColumn(lc)
|
|
}
|
|
|
|
// LocationFromColumn converts a UN/LOCODE country code to a LocationCode.
|
|
func LocationFromColumn(cc *locodecolumn.LocationCode) (*LocationCode, error) {
|
|
return (*LocationCode)(cc), nil
|
|
}
|
|
|
|
func (l *LocationCode) String() string {
|
|
syms := (*locodecolumn.LocationCode)(l).Symbols()
|
|
return string(syms[:])
|
|
}
|