// ReadFrom implements io.ReaderFrom interface. It deserializes the
// meter statistics from the wire format.
351666
func (m *MeterStats) ReadFrom(r io.Reader) (int64, error) {
	var length uint16

	// Unmarshal all elements from the reader except
	// of the list of meter band statistics.
	n, err := encoding.ReadFrom(r, &m.Meter, &length,
		&defaultPad6, &m.FlowCount, &m.PacketInCount,
		&m.ByteInCount, &m.DurationSec, &m.DurationNSec)

	limrd := io.LimitReader(r, int64(length-meterStatsLen))
	statsMaker := encoding.ReaderMakerOf(MeterBandStats{})

	nn, err := encoding.ReadSliceFrom(limrd, statsMaker, m.BandStats)
	return n + nn, err
}
1121381
func (g *GroupStatsRequest) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &g.Group, &defaultPad4)
}
848706
func (e *Experimenter) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &e.Experimenter, &e.ExpType)
}
1357622
func (s *Chan) ReadFrom(r io.Reader) {
	s.readFrom(NewReader(r))
}
623241
func (arr *IntArray) ReadFrom(r io.Reader) (n int64, err error) {
	var nn int64

	// Read length-prefix
	var length Int32
	nn, err = length.ReadFrom(r)
	if err != nil {
		return
	}
	n += nn

	// Read length bytes
	arr.Value = make([]types.Int32, length.Int32)
	for index, elem := range arr.Value {
		nn, err = elem.ReadFrom(r)
		if err != nil {
			return
		}
		arr.Value[index] = elem
		n += nn
	}

	return
}
1233358
func (m *MultipartRequest) ReadFrom(r io.Reader) (int64, error) {
	n, err := encoding.ReadFrom(r, &m.Type, &m.Flags, &defaultPad4)
	if err != nil {
		return n, err
	}

	// Just copy the rest of the body to the request.
	buf := new(bytes.Buffer)
	m.Body = buf

	nn, err := io.Copy(buf, r)
	return n + nn, err
}
895274
func (t *TableStats) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &t.Table, &defaultPad3,
		&t.ActiveCount, &t.LookupCount, &t.MatchedCount)
}
1030878
func (i *Instructions) ReadFrom(r io.Reader) (n int64, err error) {
	var instType InstructionType

	rm := func() (io.ReaderFrom, error) {
		if rm, ok := instructionMap[instType]; ok {
			rd, err := rm.MakeReader()
			*i = append(*i, rd.(Instruction))
			return rd, err
		}

		return nil, fmt.Errorf("ofp: unknown instruction type: %s", instType)
	}

	return encoding.ScanFrom(r, &instType,
		encoding.ReaderMakerFunc(rm))
}
224576
func (p *PortStatsRequest) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &p.PortNo, &defaultPad4)
}
121215
func (q *QueuePropMaxRate) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &defaultPad8, &q.Rate, &defaultPad6)
}
1287339
func (t *Time) ReadFrom(r Reader, l int) error {
	var bytes ByteSlice
	if err := (&bytes).ReadFrom(r, l); err != nil {
		return errorsp.WithStacks(err)
	}
	return errorsp.WithStacks(((*time.Time)(t)).UnmarshalBinary(bytes))
}
26641
func (sc *SwitchConfig) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &sc.Flags, &sc.MissSendLength)
}
403584
func (t *TablePropWildcards) ReadFrom(r io.Reader) (int64, error) {
	return readTablePropXM(r, &t.Fields, nil)
}
348667
func (t *TableMod) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &t.Table, &pad3{}, &t.Config)
}
108762
func (m *MeterBandDSCPRemark) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &meterBand{},
		&m.Rate, &m.BurstSize, &m.PrecLevel, &defaultPad3)
}
427710
func (q *QueuePropExperimenter) ReadFrom(r io.Reader) (int64, error) {
	var header queueProp
	n, err := encoding.ReadFrom(r, &header, &defaultPad4,
		&q.Experimenter, &defaultPad4)

	if err != nil {
		return n, err
	}

	limrd := io.LimitReader(r, int64(header.Len-queuePropLen))
	q.Data, err = ioutil.ReadAll(limrd)
	return n + int64(len(q.Data)), err
}
1179619
func (s *Slice) ReadFrom(r io.Reader) (n int64, err error) {
	const buf_SIZE = 32 * 1024
	buf := make([]byte, buf_SIZE)
	for {
		nRead, err := r.Read(buf)
		if nRead == 0 {
			if err != io.EOF {
				return n, err
			}
			break
		}
		n += int64(nRead)
		*s = append(*s, buf[:nRead]...)
		if err == io.EOF {
			break
		}

		if err != nil {
			return n, err
		}
	}

	return n, nil
}