Add blobserver.RefTypes and blob.TypeAlphabet

To be implemented later, but adding now so googledrive's blob storage implementation
can depend on them.

Change-Id: Ief374e8592bd696c79aa2b80ded11e301063750b
This commit is contained in:
Brad Fitzpatrick 2014-04-06 23:07:46 -07:00
parent bf32345778
commit bfc201f7a6
2 changed files with 20 additions and 0 deletions

View File

@ -564,3 +564,13 @@ type SizedByRef []SizedRef
func (s SizedByRef) Len() int { return len(s) }
func (s SizedByRef) Less(i, j int) bool { return s[i].Less(s[j].Ref) }
func (s SizedByRef) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
// TypeAlphabet returns the valid characters in the given blobref type.
// It returns the empty string if the typ is unknown.
func TypeAlphabet(typ string) string {
switch typ {
case "sha1":
return hexDigit
}
return ""
}

View File

@ -65,3 +65,13 @@ func EnumerateAllFrom(ctx *context.Context, src BlobEnumerator, after string, fn
}
}
}
// RefTypes returns a list of blobref types appearing on the provided enumerator.
// A blobref type is a string like "sha1", or whatever is on the left side
// of the hyphen in a blobref.
// To get the alphabet valid for the right side of the hyphen, use blob.TypeAlphabet(type).
func RefTypes(src BlobEnumerator) ([]string, error) {
// TODO(bradfitz): implement, with various short enumerate
// reads at the right places.
return []string{"sha1"}, nil
}