// ReadFrom implements io.ReaderFrom interface. It deserializes the
// message used to query the switch for configured queues from the wire
// format.
351975
func (q *QueueGetConfigRequest) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &q.Port, &defaultPad4)
}
1354870
func (p *PortStatus) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &p.Reason, &defaultPad7, &p.Port)
}
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
}
186667
func (f *BloomFilter) ReadFrom(stream io.Reader) (int64, error) {
	var m, k uint64
	err := binary.Read(stream, binary.BigEndian, &m)
	if err != nil {
		return 0, err
	}
	err = binary.Read(stream, binary.BigEndian, &k)
	if err != nil {
		return 0, err
	}
	b := &bitset.BitSet{}
	numBytes, err := b.ReadFrom(stream)
	if err != nil {
		return 0, err
	}
	f.m = uint(m)
	f.k = uint(k)
	f.b = b
	return numBytes + int64(2*binary.Size(uint64(0))), nil
}
1225881
func (s *Chan) readFrom(mr Reader) {
	// single reader, no need for Mutex
	mr.(*reader).lock = new(nullLocker)

Loop:
	for {
		buf, err := mr.ReadMsg()
		if err != nil {
			if err == io.EOF {
				break Loop // done
			}

			// unexpected error. tell the client.
			s.ErrChan <- err
			break Loop
		}

		select {
		case <-s.CloseChan:
			break Loop // told we're done
		case s.MsgChan <- buf:
			// ok seems fine. send it away
		}
	}

	close(s.MsgChan)
	// signal we're done
	s.CloseChan <- true
}
51530
func (c *PacketConn) ReadFrom(b []byte) (int, net.Addr, error) {
	deadline := c.readCancel()

	var addr tcpip.FullAddress
	read, err := commonRead(c.ep, c.wq, deadline, &addr, c, false)
	if err != nil {
		return 0, nil, err
	}

	return copy(b, read), fullToUDPAddr(addr), nil
}
224576
func (p *PortStatsRequest) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &p.PortNo, &defaultPad4)
}
678926
func (p *PacketIn) ReadFrom(r io.Reader) (int64, error) {
	// Read the Packet-In header, list of match rules
	// that used to match the processing packet,
	// then the original frame, if any.
	n, err := encoding.ReadFrom(r, &p.Buffer, &p.Length,
		&p.Reason, &p.Table, &p.Cookie, &p.Match, &defaultPad2)
	if err != nil {
		return n, err
	}
	p.Data, err = ioutil.ReadAll(r)
	if err != nil {
		return n + int64(len(p.Data)), err
	}

	return n + int64(len(p.Data)), nil
}
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))
}
528645
func (a *p2SHScript) ReadFrom(r io.Reader) (n int64, err error) {
	//read length
	var lenBytes [4]byte

	read, err := io.ReadFull(r, lenBytes[:])
	n += int64(read)
	if err != nil {
		return n, err
	}

	length := binary.LittleEndian.Uint32(lenBytes[:])

	script := make([]byte, length)

	read, err = io.ReadFull(r, script)
	n += int64(read)
	if err != nil {
		return n, err
	}

	*a = script

	return n, nil
}
1051321
func (tt *TagType) ReadFrom(r io.Reader) (n int64, err error) {
	err = binary.Read(r, binary.BigEndian, tt)
	if err != nil {
		return 0, err
	}
	return 1, nil
}
848706
func (e *Experimenter) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &e.Experimenter, &e.ExpType)
}
191099
func (m *ExperimenterMultipartHeader) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &m.Experimenter, &m.ExpType)
}
526692
func (e *ErrorExperimenter) ReadFrom(r io.Reader) (n int64, err error) {
	var etype ErrType
	n, err = encoding.ReadFrom(r, &etype, &e.ExpType, &e.Experimenter)
	if err != nil {
		return n, err
	}

	e.Data, err = ioutil.ReadAll(r)
	if err != nil {
		return
	}

	return n + int64(len(e.Data)), nil
}
665482
func (ac *arrayContainer) readFrom(stream io.Reader) (int, error) {
	buf := uint16SliceAsByteSlice(ac.content)
	return io.ReadFull(stream, buf)
}
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
}
450306
func (w *Writer) ReadFrom(src io.Reader) (n int64, err error) {
	var nn int
	for err == nil {
		if w.Available() == 0 {
			err = w.FlushFragment()
			continue
		}

		// We copy the behavior of bufio.Writer here.
		// Also, from the docs on io.ReaderFrom:
		//   ReadFrom reads data from r until EOF or error.
		//
		// See https://codereview.appspot.com/76400048/#ps1
		const maxEmptyReads = 100
		var nr int
		for nr < maxEmptyReads {
			nn, err = src.Read(w.buf[w.n:])
			if nn != 0 || err != nil {
				break
			}
			nr++
		}
		if nr == maxEmptyReads {
			return n, io.ErrNoProgress
		}

		w.n += nn
		n += int64(nn)
	}
	if err == io.EOF {
		// NOTE: Do not flush preemtively.
		// See the Write() sources for more info.
		err = nil
		w.dirty = true
	}
	return n, err
}