Documentation ¶
Overview ¶
Package easyphpserialize contains marshaler/unmarshaler interfaces and helper functions.
Index ¶
- func Marshal(v Marshaler) ([]byte, error)
- func MarshalToHTTPResponseWriter(v Marshaler, w http.ResponseWriter) (started bool, written int, err error)
- func MarshalToWriter(v Marshaler, w io.Writer) (written int, err error)
- func Unmarshal(data []byte, v Unmarshaler) error
- func UnmarshalFromReader(r io.Reader, v Unmarshaler) error
- type Marshaler
- type MarshalerUnmarshaler
- type Optional
- type RawMessage
- type UnknownsMarshaler
- type UnknownsUnmarshaler
- type Unmarshaler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶
Marshal returns data as a single byte slice. Method is suboptimal as the data is likely to be copied from a chain of smaller chunks.
func MarshalToHTTPResponseWriter ¶
func MarshalToHTTPResponseWriter(v Marshaler, w http.ResponseWriter) (started bool, written int, err error)
MarshalToHTTPResponseWriter sets Content-Length and Content-Type headers for the http.ResponseWriter, and send the data to the writer. started will be equal to false if an error occurred before any http.ResponseWriter methods were actually invoked (in this case a 500 reply is possible).
func MarshalToWriter ¶
MarshalToWriter marshals the data to an io.Writer.
func Unmarshal ¶
func Unmarshal(data []byte, v Unmarshaler) error
Unmarshal decodes the PHPSerialize in data into the object.
func UnmarshalFromReader ¶
func UnmarshalFromReader(r io.Reader, v Unmarshaler) error
UnmarshalFromReader reads all the data in the reader and decodes as PHPSerialize into the object.
Types ¶
type MarshalerUnmarshaler ¶
type MarshalerUnmarshaler interface { Marshaler Unmarshaler }
MarshalerUnmarshaler is an easyphpserialize-compatible marshaler/unmarshaler interface.
type Optional ¶
type Optional interface {
IsDefined() bool
}
Optional defines an undefined-test method for a type to integrate with 'omitempty' logic.
type RawMessage ¶
type RawMessage []byte
RawMessage is a raw piece of PHPSerialize (number, string, bool, object, array or null) that is extracted without parsing and output as is during marshaling.
func (*RawMessage) IsDefined ¶
func (v *RawMessage) IsDefined() bool
IsDefined is required for integration with omitempty easyphpserialize logic.
func (*RawMessage) MarshalEasyPHPSerialize ¶
func (v *RawMessage) MarshalEasyPHPSerialize(w *pwriter.Writer)
MarshalEasyPHPSerialize does PHPSerialize marshaling using easyphpserialize interface.
func (RawMessage) MarshalPHPSerialize ¶
func (v RawMessage) MarshalPHPSerialize() ([]byte, error)
MarshalPHPSerialize implements easyphpserialize.Marshaler interface.
func (*RawMessage) UnmarshalEasyPHPSerialize ¶
func (v *RawMessage) UnmarshalEasyPHPSerialize(l *plexer.Lexer)
UnmarshalEasyPHPSerialize does PHPSerialize unmarshaling using easyphpserialize interface.
func (*RawMessage) UnmarshalPHPSerialize ¶
func (v *RawMessage) UnmarshalPHPSerialize(data []byte) error
UnmarshalPHPSerialize implements easyphpserialize.Unmarshaler interface.
type UnknownsMarshaler ¶
UnknownsMarshaler provides a method to write additional struct fields
type UnknownsUnmarshaler ¶
UnknownsUnmarshaler provides a method to unmarshal unknown struct fileds and save them as you want
type Unmarshaler ¶
Marshaler is an easyphpserialize-compatible unmarshaler interface.
Directories ¶
Path | Synopsis |
---|---|
Package bootstrap implements the bootstrapping logic: generation of a .go file to launch the actual generator and launching the generator itself.
|
Package bootstrap implements the bootstrapping logic: generation of a .go file to launch the actual generator and launching the generator itself. |
Package buffer implements a buffer for serialization, consisting of a chain of []byte-s to reduce copying and to allow reuse of individual chunks.
|
Package buffer implements a buffer for serialization, consisting of a chain of []byte-s to reduce copying and to allow reuse of individual chunks. |
Package pwriter contains a PHP Serialize writer.
|
Package pwriter contains a PHP Serialize writer. |