// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.

package signaling

import (
	json "encoding/json"
	easyjson "github.com/mailru/easyjson"
	jlexer "github.com/mailru/easyjson/jlexer"
	jwriter "github.com/mailru/easyjson/jwriter"
)

// suppress unused package warning
var (
	_ *json.RawMessage
	_ *jlexer.Lexer
	_ *jwriter.Writer
	_ easyjson.Marshaler
)

func easyjson9289e183DecodeGithubComStrukturagNextcloudSpreedSignaling(in *jlexer.Lexer, out *SendOfferMessage) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		if isTopLevel {
			in.Consumed()
		}
		in.Skip()
		return
	}
	in.Delim('{')
	for !in.IsDelim('}') {
		key := in.UnsafeFieldName(false)
		in.WantColon()
		if in.IsNull() {
			in.Skip()
			in.WantComma()
			continue
		}
		switch key {
		case "messageid":
			out.MessageId = string(in.String())
		case "sessionid":
			out.SessionId = string(in.String())
		case "data":
			if in.IsNull() {
				in.Skip()
				out.Data = nil
			} else {
				if out.Data == nil {
					out.Data = new(MessageClientMessageData)
				}
				(*out.Data).UnmarshalEasyJSON(in)
			}
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func easyjson9289e183EncodeGithubComStrukturagNextcloudSpreedSignaling(out *jwriter.Writer, in SendOfferMessage) {
	out.RawByte('{')
	first := true
	_ = first
	if in.MessageId != "" {
		const prefix string = ",\"messageid\":"
		first = false
		out.RawString(prefix[1:])
		out.String(string(in.MessageId))
	}
	{
		const prefix string = ",\"sessionid\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.SessionId))
	}
	{
		const prefix string = ",\"data\":"
		out.RawString(prefix)
		if in.Data == nil {
			out.RawString("null")
		} else {
			(*in.Data).MarshalEasyJSON(out)
		}
	}
	out.RawByte('}')
}

// MarshalJSON supports json.Marshaler interface
func (v SendOfferMessage) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjson9289e183EncodeGithubComStrukturagNextcloudSpreedSignaling(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}

// MarshalEasyJSON supports easyjson.Marshaler interface
func (v SendOfferMessage) MarshalEasyJSON(w *jwriter.Writer) {
	easyjson9289e183EncodeGithubComStrukturagNextcloudSpreedSignaling(w, v)
}

// UnmarshalJSON supports json.Unmarshaler interface
func (v *SendOfferMessage) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson9289e183DecodeGithubComStrukturagNextcloudSpreedSignaling(&r, v)
	return r.Error()
}

// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *SendOfferMessage) UnmarshalEasyJSON(l *jlexer.Lexer) {
	easyjson9289e183DecodeGithubComStrukturagNextcloudSpreedSignaling(l, v)
}
func easyjson9289e183DecodeGithubComStrukturagNextcloudSpreedSignaling1(in *jlexer.Lexer, out *AsyncRoomMessage) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		if isTopLevel {
			in.Consumed()
		}
		in.Skip()
		return
	}
	in.Delim('{')
	for !in.IsDelim('}') {
		key := in.UnsafeFieldName(false)
		in.WantColon()
		if in.IsNull() {
			in.Skip()
			in.WantComma()
			continue
		}
		switch key {
		case "type":
			out.Type = string(in.String())
		case "sessionid":
			out.SessionId = string(in.String())
		case "clienttype":
			out.ClientType = string(in.String())
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func easyjson9289e183EncodeGithubComStrukturagNextcloudSpreedSignaling1(out *jwriter.Writer, in AsyncRoomMessage) {
	out.RawByte('{')
	first := true
	_ = first
	{
		const prefix string = ",\"type\":"
		out.RawString(prefix[1:])
		out.String(string(in.Type))
	}
	if in.SessionId != "" {
		const prefix string = ",\"sessionid\":"
		out.RawString(prefix)
		out.String(string(in.SessionId))
	}
	if in.ClientType != "" {
		const prefix string = ",\"clienttype\":"
		out.RawString(prefix)
		out.String(string(in.ClientType))
	}
	out.RawByte('}')
}

// MarshalJSON supports json.Marshaler interface
func (v AsyncRoomMessage) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjson9289e183EncodeGithubComStrukturagNextcloudSpreedSignaling1(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}

// MarshalEasyJSON supports easyjson.Marshaler interface
func (v AsyncRoomMessage) MarshalEasyJSON(w *jwriter.Writer) {
	easyjson9289e183EncodeGithubComStrukturagNextcloudSpreedSignaling1(w, v)
}

// UnmarshalJSON supports json.Unmarshaler interface
func (v *AsyncRoomMessage) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson9289e183DecodeGithubComStrukturagNextcloudSpreedSignaling1(&r, v)
	return r.Error()
}

// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *AsyncRoomMessage) UnmarshalEasyJSON(l *jlexer.Lexer) {
	easyjson9289e183DecodeGithubComStrukturagNextcloudSpreedSignaling1(l, v)
}
func easyjson9289e183DecodeGithubComStrukturagNextcloudSpreedSignaling2(in *jlexer.Lexer, out *AsyncMessage) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		if isTopLevel {
			in.Consumed()
		}
		in.Skip()
		return
	}
	in.Delim('{')
	for !in.IsDelim('}') {
		key := in.UnsafeFieldName(false)
		in.WantColon()
		if in.IsNull() {
			in.Skip()
			in.WantComma()
			continue
		}
		switch key {
		case "sendtime":
			if data := in.Raw(); in.Ok() {
				in.AddError((out.SendTime).UnmarshalJSON(data))
			}
		case "type":
			out.Type = string(in.String())
		case "message":
			if in.IsNull() {
				in.Skip()
				out.Message = nil
			} else {
				if out.Message == nil {
					out.Message = new(ServerMessage)
				}
				(*out.Message).UnmarshalEasyJSON(in)
			}
		case "room":
			if in.IsNull() {
				in.Skip()
				out.Room = nil
			} else {
				if out.Room == nil {
					out.Room = new(BackendServerRoomRequest)
				}
				(*out.Room).UnmarshalEasyJSON(in)
			}
		case "permissions":
			if in.IsNull() {
				in.Skip()
				out.Permissions = nil
			} else {
				in.Delim('[')
				if out.Permissions == nil {
					if !in.IsDelim(']') {
						out.Permissions = make([]Permission, 0, 4)
					} else {
						out.Permissions = []Permission{}
					}
				} else {
					out.Permissions = (out.Permissions)[:0]
				}
				for !in.IsDelim(']') {
					var v1 Permission
					v1 = Permission(in.String())
					out.Permissions = append(out.Permissions, v1)
					in.WantComma()
				}
				in.Delim(']')
			}
		case "asyncroom":
			if in.IsNull() {
				in.Skip()
				out.AsyncRoom = nil
			} else {
				if out.AsyncRoom == nil {
					out.AsyncRoom = new(AsyncRoomMessage)
				}
				(*out.AsyncRoom).UnmarshalEasyJSON(in)
			}
		case "sendoffer":
			if in.IsNull() {
				in.Skip()
				out.SendOffer = nil
			} else {
				if out.SendOffer == nil {
					out.SendOffer = new(SendOfferMessage)
				}
				(*out.SendOffer).UnmarshalEasyJSON(in)
			}
		case "id":
			out.Id = string(in.String())
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func easyjson9289e183EncodeGithubComStrukturagNextcloudSpreedSignaling2(out *jwriter.Writer, in AsyncMessage) {
	out.RawByte('{')
	first := true
	_ = first
	{
		const prefix string = ",\"sendtime\":"
		out.RawString(prefix[1:])
		out.Raw((in.SendTime).MarshalJSON())
	}
	{
		const prefix string = ",\"type\":"
		out.RawString(prefix)
		out.String(string(in.Type))
	}
	if in.Message != nil {
		const prefix string = ",\"message\":"
		out.RawString(prefix)
		(*in.Message).MarshalEasyJSON(out)
	}
	if in.Room != nil {
		const prefix string = ",\"room\":"
		out.RawString(prefix)
		(*in.Room).MarshalEasyJSON(out)
	}
	if len(in.Permissions) != 0 {
		const prefix string = ",\"permissions\":"
		out.RawString(prefix)
		{
			out.RawByte('[')
			for v2, v3 := range in.Permissions {
				if v2 > 0 {
					out.RawByte(',')
				}
				out.String(string(v3))
			}
			out.RawByte(']')
		}
	}
	if in.AsyncRoom != nil {
		const prefix string = ",\"asyncroom\":"
		out.RawString(prefix)
		(*in.AsyncRoom).MarshalEasyJSON(out)
	}
	if in.SendOffer != nil {
		const prefix string = ",\"sendoffer\":"
		out.RawString(prefix)
		(*in.SendOffer).MarshalEasyJSON(out)
	}
	{
		const prefix string = ",\"id\":"
		out.RawString(prefix)
		out.String(string(in.Id))
	}
	out.RawByte('}')
}

// MarshalJSON supports json.Marshaler interface
func (v AsyncMessage) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjson9289e183EncodeGithubComStrukturagNextcloudSpreedSignaling2(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}

// MarshalEasyJSON supports easyjson.Marshaler interface
func (v AsyncMessage) MarshalEasyJSON(w *jwriter.Writer) {
	easyjson9289e183EncodeGithubComStrukturagNextcloudSpreedSignaling2(w, v)
}

// UnmarshalJSON supports json.Unmarshaler interface
func (v *AsyncMessage) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson9289e183DecodeGithubComStrukturagNextcloudSpreedSignaling2(&r, v)
	return r.Error()
}

// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *AsyncMessage) UnmarshalEasyJSON(l *jlexer.Lexer) {
	easyjson9289e183DecodeGithubComStrukturagNextcloudSpreedSignaling2(l, v)
}
