func DeserializePlace(r io.Reader, api rbxapi.Root) (root *rbxfile.Root, err error) {
	codec := RobloxCodec{Mode: ModePlace, API: api}
	return Serializer{
		Encoder:    codec,
		Decoder:    codec,
		DecoderXML: xml.RobloxCodec{API: api},
	}.Deserialize(r)
}
Deserialize decodes data from r into a Root structure using the default
decoder. Data is interpreted as a Roblox place file. An optional API can be
given to ensure more correct data.
package bin
import (
	"bufio"
	"bytes"
	"errors"
	"github.com/robloxapi/rbxapi"
	"github.com/robloxapi/rbxfile"
	"github.com/robloxapi/rbxfile/xml"
	"io"
)
type Decoder interface {
	Decode(model *FormatModel) (root *rbxfile.Root, err error)
}
type Encoder interface {
	Encode(root *rbxfile.Root) (model *FormatModel, err error)
}
type Serializer struct {
	Decoder Decoder
	Encoder Encoder
	DecoderXML xml.Decoder
}
func NewSerializer(d Decoder, e Encoder) Serializer {
	s := Serializer{
		Decoder:    d,
		Encoder:    e,
		DecoderXML: xml.RobloxCodec{},
	}
	if d == nil || e == nil {
		var codec RobloxCodec
		if d == nil {
			s.Decoder = codec
		}
		if e == nil {
			s.Encoder = codec
		}
	}
	return s
}
func (s Serializer) Deserialize(r io.Reader) (root *rbxfile.Root, err error) {
	if s.Decoder == nil {
		return nil, errors.New("a decoder has not been not specified")
	}
	if s.DecoderXML != nil {
		var buf *bufio.Reader
		if br, ok := r.(*bufio.Reader); ok {
			buf = br
		} else {
			buf = bufio.NewReader(r)
		}
		sig, err := buf.Peek(len(RobloxSig) + len(BinaryMarker))
		if err != nil {
			return nil, err
		}
		if !bytes.Equal(sig[:len(RobloxSig)], []byte(RobloxSig)) {
			return nil, ErrInvalidSig
		}
		if !bytes.Equal(sig[len(RobloxSig):], []byte(BinaryMarker)) {
			return xml.NewSerializer(s.DecoderXML, nil).Deserialize(buf)
		}
		r = buf
	}
	model := new(FormatModel)
	if _, err = model.ReadFrom(r); err != nil {
		return nil, errors.New("error parsing format: " + err.Error())
	}
	root, err = s.Decoder.Decode(model)
	if err != nil {
		return nil, errors.New("error decoding data: " + err.Error())
	}
	return root, nil
}
func (s Serializer) Serialize(w io.Writer, root *rbxfile.Root) (err error) {
	if s.Encoder == nil {
		return errors.New("an encoder has not been not specified")
	}
	model, err := s.Encoder.Encode(root)
	if err != nil {
		return errors.New("error encoding data: " + err.Error())
	}
	if _, err = model.WriteTo(w); err != nil {
		return errors.New("error encoding format: " + err.Error())
	}
	return nil
}