// NewPayloadList parse a stream and reads PayloadLists
358924
func NewPayloadList(body io.ReadCloser) (PayloadList, error) {
	parser := xml.NewDecoder(body)

	// return a composite result and offer walk/close options
	pl := PayloadList{
		body:   body,
		parser: parser,
		delim:  CompactDefaultDelim,
	}
	for {
		token, err := parser.Token()
		if err != nil {
			return pl, err
		}
		switch t := token.(type) {
		case xml.StartElement:
			switch t.Name.Local {
			case XMLElemRETS, XMLElemRETSStatus:
				rets, er := ResponseTag(t).Parse()
				if err != nil {
					return pl, er
				}
				pl.Response = *rets
				return pl, nil
			case "DELIMITER":
				pl.delim, err = DelimiterTag(t).Parse()
				if err != nil {
					return pl, err
				}
			}
		}
	}
}
967277
func NewPeer(p *p2p.Peer, rw p2p.MsgReadWriter, spec *Spec) *Peer {
	return &Peer{
		Peer: p,
		rw:   rw,
		spec: spec,
	}
}
646052
func (o *GetItemsDefault) WithPayload(payload *models.Error) *GetItemsDefault {
	o.Payload = payload
	return o
}
1256845
func (pn *PushNotification) AddPayload(p *Payload) {
	// This deserves some explanation.
	//
	// Setting an exported field of type int to 0
	// triggers the omitempty behavior if you've set it.
	// Since the badge is optional, we should omit it if
	// it's not set. However, we want to include it if the
	// value is 0, so there's a hack in push_notification.go
	// that exploits the fact that Apple treats -1 for a
	// badge value as though it were 0 (i.e. it clears the
	// badge but doesn't stop the notification from going
	// through successfully.)
	//
	// Still a hack though :)
	if p.Badge == 0 {
		p.Badge = -1
	}
	pn.Set("aps", p)
}
236140
func (o *GetUserByNameOK) WithPayload(payload *models.User) *GetUserByNameOK {
	o.Payload = payload
	return o
}
355812
func (o *CreateDefault) WithPayload(payload *models.Error) *CreateDefault {
	o.Payload = payload
	return o
}
1138672
func NewPayloadsBuffer(next uint64) PayloadsBuffer {
	return &PayloadsBufferImpl{
		buf:       make(map[uint64]*proto.Payload),
		readyChan: make(chan struct{}, 1),
		next:      next,
		logger:    util.GetLogger(util.StateLogger, ""),
	}
}
887649
func NewPlist(label string, binPath string, args []string, envVars []EnvVar, logPath string, comment string) Plist {
	return Plist{
		label:     label,
		binPath:   binPath,
		args:      args,
		envVars:   envVars,
		keepAlive: true,
		runAtLoad: false,
		logPath:   logPath,
		comment:   comment,
	}
}
594569
func (o *GetAuthCallbackDefault) WithPayload(payload *models.Error) *GetAuthCallbackDefault {
	o.Payload = payload
	return o
}
487543
func (o *GetAccountDefault) WithPayload(payload *models.Error) *GetAccountDefault {
	o.Payload = payload
	return o
}
935860
func (s *GossipStateProviderImpl) AddPayload(payload *proto.Payload) error {
	return s.addPayload(payload, s.config.BlockingMode)
}
28694
func (o *PutServiceIDFailure) WithPayload(payload models.Error) *PutServiceIDFailure {
	o.Payload = payload
	return o
}
34275
func (o *GetItemsOK) WithPayload(payload []models.Item) *GetItemsOK {
	o.Payload = payload
	return o
}
1023013
func (o *GetEndpointIDConfigOK) WithPayload(payload *models.EndpointConfigurationStatus) *GetEndpointIDConfigOK {
	o.Payload = payload
	return o
}
1230012
func (i *gatewayHandler) newDagFromReader(r io.Reader) (ipld.Node, error) {
	// TODO(cryptix): change and remove this helper once PR1136 is merged
	// return ufs.AddFromReader(i.node, r.Body)
	return importer.BuildDagFromReader(
		i.node.DAG,
		chunker.DefaultSplitter(r))
}
1083268
func (o *GetIDNotFound) WithPayload(payload *models.Error) *GetIDNotFound {
	o.Payload = payload
	return o
}
725295
func (w *WebRTCSignalMessage) ParsePayload() (*Payload, error) {
	w.mu.Lock()
	defer w.mu.Unlock()

	if w.isParsed {
		return w.parsedPayload, nil
	}

	payload := &Payload{}
	if err := json.Unmarshal(w.Payload, payload); err != nil {
		return nil, err
	}

	w.parsedPayload = payload
	return payload, nil
}