Unverified Commit 2b341069 authored by Blake Mizerany's avatar Blake Mizerany Committed by GitHub
Browse files

types/model: remove (*Digest).Scan and Digest.Value (#3605)

parent c00fee69
package model package model
import ( import (
"database/sql"
"database/sql/driver"
"errors"
"fmt"
"log/slog" "log/slog"
"strings" "strings"
"unicode" "unicode"
...@@ -44,32 +40,9 @@ func (d Digest) LogValue() slog.Value { ...@@ -44,32 +40,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 {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment