// ReadFrom reads a binary representation of Buckets (such as might
// have been written by WriteTo()) from an i/o stream. It returns the number
// of bytes read.
425114
func (b *Buckets) ReadFrom(stream io.Reader) (int64, error) {
	var bucketSize, max uint8
	var count, len uint64
	err := binary.Read(stream, binary.BigEndian, &bucketSize)
	if err != nil {
		return 0, err
	}
	err = binary.Read(stream, binary.BigEndian, &max)
	if err != nil {
		return 0, err
	}
	err = binary.Read(stream, binary.BigEndian, &count)
	if err != nil {
		return 0, err
	}
	err = binary.Read(stream, binary.BigEndian, &len)
	if err != nil {
		return 0, err
	}
	data := make([]byte, len)
	err = binary.Read(stream, binary.BigEndian, &data)
	if err != nil {
		return 0, err
	}
	b.bucketSize = bucketSize
	b.max = max
	b.count = uint(count)
	b.data = data
	return int64(int(len) + 2*binary.Size(uint8(0)) + 2*binary.Size(uint64(0))), nil
}
662036
func (i *InverseBloomFilter) ReadFrom(stream io.Reader) (int64, error) {
	decoded, capacity, size, err := i.decodeToArray(stream)
	if err != nil {
		return int64(0), err
	}

	// Create []*[]byte and point to each item in decoded
	decodedWithPointers := make([]*[]byte, capacity)
	for p := range decodedWithPointers {
		if len(decoded[p]) == 0 {
			decodedWithPointers[p] = nil
		} else {
			decodedWithPointers[p] = &decoded[p]
		}
	}

	i.array = decodedWithPointers
	i.capacity = uint(capacity)
	return int64(size) + int64(2*binary.Size(uint64(0))), nil
}
34900
func (g *GroupFeatures) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &g.Types, &g.Capabilities,
		&g.MaxGroups, &g.Actions)
}
39471
func (a *ActionCopyTTLOut) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &defaultPad8)
}
28204
func (b *Bytes) ReadNFrom(n int64, r io.Reader) (m int64, err error) {
	b.bytes, m, err = b.readNFrom(n, r)
	return m, err
}
214537
func (a *ActionSetQueue) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &defaultPad4, &a.QueueID)
}
648374
func (q *QueueGetConfigReply) ReadFrom(r io.Reader) (int64, error) {
	n, err := encoding.ReadFrom(r, &q.Port, &defaultPad4)
	if err != nil {
		return n, err
	}

	// The passed reader should be limited to the whole
	// OpenFlow message, thus return EOF error when the
	// messages ends. Otherwise this implementation will
	// read the packet queues indefinitely.
	queueMaker := encoding.ReaderMakerOf(PacketQueue{})
	nn, err := encoding.ReadSliceFrom(r, queueMaker, q.Queues)
	return n + nn, err
}
1114032
func (i *InstructionGotoTable) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &instruction{}, &i.Table, &defaultPad3)
}
1350585
func (f *FlowMod) ReadFrom(r io.Reader) (int64, error) {
	// Set the list of instructions to nil, if someone will decide
	// to reuse the same exemplar for multiple deserializations.
	f.Instructions = nil

	return encoding.ReadFrom(r, &f.Cookie, &f.CookieMask, &f.Table,
		&f.Command, &f.IdleTimeout, &f.HardTimeout, &f.Priority,
		&f.Buffer, &f.OutPort, &f.OutGroup, &f.Flags, &defaultPad2,
		&f.Match, &f.Instructions,
	)
}
1135270
func (i *RawVInt) ReadFrom(r Reader, l int) error {
	if l < 0 {
		return errorsp.WithStacksAndMessage(ErrBadFormat, "l = %d", l)
	}
	var v RawVInt
	n := uint(0)
	for ; l > 0; l-- {
		b, err := r.ReadByte()
		if err != nil {
			return errorsp.WithStacks(err)
		}
		v |= (RawVInt(b) & 0xff) << n
		n += 8
	}
	*i = v
	return nil
}
1008088
func (er *EchoRequest) ReadFrom(r io.Reader) (n int64, err error) {
	// The header of the echo request will be unmarshalled by the
	// previous read, so we need to read up to the end of the
	// buffer. So it is responsibility of the called to provide
	// fixed-length reader.
	er.Data, err = ioutil.ReadAll(r)
	if err != nil {
		return
	}

	return int64(len(er.Data)), nil
}
567166
func (w *Writer) ReadFrom(r io.Reader) (int64, error) {
	// anticipatory flush
	if err := w.Flush(); err != nil {
		return 0, err
	}

	w.buf = w.buf[0:cap(w.buf)] // expand buffer

	var nn int64  // written
	var err error // error
	var x int     // read

	// 1:1 reads and writes
	for err == nil {
		x, err = r.Read(w.buf)
		if x > 0 {
			n, werr := w.w.Write(w.buf[:x])
			nn += int64(n)

			if err != nil {
				if n < x && n > 0 {
					w.pushback(n - x)
				}
				return nn, werr
			}
			if n < x {
				w.pushback(n - x)
				return nn, io.ErrShortWrite
			}
		} else if err == nil {
			err = io.ErrNoProgress
			break
		}
	}
	if err != io.EOF {
		return nn, err
	}

	// we only clear here
	// because we are sure
	// the writes have
	// succeeded. otherwise,
	// we retain the data in case
	// future writes succeed.
	w.buf = w.buf[0:0]

	return nn, nil
}
95918
func (b *Buffer) ReadFrom(r io.Reader) (int64, error) {
	version := b.preOp()
	n, err := b.buf.ReadFrom(r)
	b.postOp(version)
	return n, err
}
1321403
func (b *ByteBuffer) ReadFrom(r io.Reader) (int64, error) {
	p := b.B
	nStart := int64(len(p))
	nMax := int64(cap(p))
	n := nStart
	if nMax == 0 {
		nMax = 64
		p = make([]byte, nMax)
	} else {
		p = p[:nMax]
	}
	for {
		if n == nMax {
			nMax *= 2
			bNew := make([]byte, nMax)
			copy(bNew, p)
			p = bNew
		}
		nn, err := r.Read(p[n:])
		n += int64(nn)
		if err != nil {
			b.B = p[:n]
			n -= nStart
			if err == io.EOF {
				return n, nil
			}
			return n, err
		}
	}
}
888758
func (h *Header) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &h.Version, &h.Type, &h.Length, &h.Transaction)
}
1279636
func (m *MeterBandStats) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &m.PacketBandCount, &m.ByteBandCount)
}
191099
func (m *ExperimenterMultipartHeader) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &m.Experimenter, &m.ExpType)
}