package refs

import (
	refs "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs/grpc"
)

// String returns string representation of ChecksumType.
func (t ChecksumType) String() string {
	return ChecksumTypeToGRPC(t).String()
}

// FromString parses ChecksumType from a string representation.
// It is a reverse action to String().
//
// Returns true if s was parsed successfully.
func (t *ChecksumType) FromString(s string) bool {
	g, ok := refs.ChecksumType_value[s]

	if ok {
		*t = ChecksumTypeFromGRPC(refs.ChecksumType(g))
	}

	return ok
}

// String returns string representation of SignatureScheme.
func (t SignatureScheme) String() string {
	return refs.SignatureScheme(t).String()
}

// FromString parses SignatureScheme from a string representation.
// It is a reverse action to String().
//
// Returns true if s was parsed successfully.
func (t *SignatureScheme) FromString(s string) bool {
	g, ok := refs.SignatureScheme_value[s]

	if ok {
		*t = SignatureScheme(refs.SignatureScheme(g))
	}

	return ok
}