github.com/TeaOSLab/EdgeNode@v1.3.8/internal/utils/kvstore/value_encoder_string.go (about) 1 // Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . 2 3 package kvstore 4 5 type StringValueEncoder[T string] struct { 6 } 7 8 func NewStringValueEncoder[T string]() *StringValueEncoder[T] { 9 return &StringValueEncoder[T]{} 10 } 11 12 func (this *StringValueEncoder[T]) Encode(value T) ([]byte, error) { 13 return []byte(value), nil 14 } 15 16 func (this *StringValueEncoder[T]) EncodeField(value T, fieldName string) ([]byte, error) { 17 _ = fieldName 18 return this.Encode(value) 19 } 20 21 func (this *StringValueEncoder[T]) Decode(valueData []byte) (value T, err error) { 22 value = T(valueData) 23 return 24 }