types/model: remove (*Digest).Scan and Digest.Value (#3589)
This commit is contained in:
parent
9446b795b5
commit
42f2cc408e
1 changed files with 0 additions and 23 deletions
|
@ -44,32 +44,9 @@ func (d Digest) LogValue() slog.Value {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ driver.Valuer = Digest{}
|
|
||||||
_ sql.Scanner = (*Digest)(nil)
|
|
||||||
_ slog.LogValuer = Digest{}
|
_ slog.LogValuer = Digest{}
|
||||||
)
|
)
|
||||||
|
|
||||||
// Scan implements the sql.Scanner interface.
|
|
||||||
func (d *Digest) Scan(src any) error {
|
|
||||||
if d.IsValid() {
|
|
||||||
return errors.New("model.Digest: illegal Scan on valid Digest")
|
|
||||||
}
|
|
||||||
switch v := src.(type) {
|
|
||||||
case string:
|
|
||||||
*d = ParseDigest(v)
|
|
||||||
return nil
|
|
||||||
case []byte:
|
|
||||||
*d = ParseDigest(string(v))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return fmt.Errorf("model.Digest: invalid Scan source %T", src)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Value implements the driver.Valuer interface.
|
|
||||||
func (d Digest) Value() (driver.Value, error) {
|
|
||||||
return d.String(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParseDigest parses a string in the form of "<digest-type>-<digest>" into a
|
// ParseDigest parses a string in the form of "<digest-type>-<digest>" into a
|
||||||
// Digest.
|
// Digest.
|
||||||
func ParseDigest(s string) Digest {
|
func ParseDigest(s string) Digest {
|
||||||
|
|
Loading…
Reference in a new issue