-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,33 @@ | ||
package gsr | ||
|
||
// Marshaler interface for Marshal/Unmarshal data | ||
// Marshaler interface | ||
type Marshaler interface { | ||
Marshal(v interface{}) ([]byte, error) | ||
Unmarshal(data []byte, ptr interface{}) error | ||
} | ||
|
||
// Unmarshaler interface | ||
type Unmarshaler interface { | ||
Unmarshal(v []byte, ptr interface{}) error | ||
} | ||
|
||
// DataMarshaler interface for Marshal/Unmarshal data | ||
type DataMarshaler interface { | ||
Marshaler | ||
Unmarshaler | ||
} | ||
|
||
// MarshalFunc define | ||
type MarshalFunc func(v interface{}) ([]byte, error) | ||
|
||
// Marshal implements the Marshaler | ||
func (m MarshalFunc) Marshal(v interface{}) ([]byte, error) { | ||
return m(v) | ||
} | ||
|
||
// UnmarshalFunc define | ||
type UnmarshalFunc func(v []byte, ptr interface{}) error | ||
|
||
// Unmarshal implements the Unmarshaler | ||
func (u UnmarshalFunc) Unmarshal(v []byte, ptr interface{}) error { | ||
return u(v, ptr) | ||
} |