func (self *Converter) ReadEncodedString(input interface{}, fallback strencoding.Handler) []byte { if input == nil { panic("Expecting a value (type 'string'), but it's missing") } str, ok := input.(string) if !ok { panic(fmt.Sprintf("The given thing of type %T is not a string", input)) } data, err := strencoding.Encode(str, fallback) if err != nil { panic(err) } return data }
func (self *Converter) ReadBucketId(input interface{}) bucket.Id { if input == nil { panic("Expecting a bucket id but value is missing") } switch input := input.(type) { case string: bucketIdBinary, err := strencoding.Encode(input, strencoding.Base32) if err != nil { panic(err) } return bucket.Id(bucketIdBinary) case []byte: return bucket.Id(self.ReadBinary(input)) case bucket.Id: return input default: panic(fmt.Sprintf("Expecting a string or a binary but got a %T", input)) } }
func StringToElement(str string) (value []byte, err error) { return strencoding.Encode(str, strencoding.String) }