stealing
This commit is contained in:
26
storage/packable/packable.go
Normal file
26
storage/packable/packable.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package packable
|
||||
|
||||
type Packable interface {
|
||||
Encode() ([]byte, error)
|
||||
Decode([]byte) error
|
||||
}
|
||||
|
||||
type String string
|
||||
|
||||
func (s *String) String() string {
|
||||
return string(*s)
|
||||
}
|
||||
|
||||
func (s *String) Encode() ([]byte, error) {
|
||||
return []byte(*s), nil
|
||||
}
|
||||
|
||||
func (s *String) Decode(b []byte) error {
|
||||
*s = String(string(b))
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewString(s string) *String {
|
||||
w := String(s)
|
||||
return &w
|
||||
}
|
||||
Reference in New Issue
Block a user