// ReadFrom implements io.ReaderFrom interface. It deserializes
// the "experimenter" action from a wire format.
506514
func (a *ActionExperimenter) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &defaultPad4, &a.Experimenter)
}
403584
func (t *TablePropWildcards) ReadFrom(r io.Reader) (int64, error) {
	return readTablePropXM(r, &t.Fields, nil)
}
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
}
1018153
func (m *Message) ReadFrom(r io.Reader) (int64, error) {
	lengthBuf, n1, err := readUntilSpace(r)
	if err != nil {
		return 0, err
	}
	length, err := strconv.Atoi(string(lengthBuf))
	if err != nil {
		return 0, err
	}
	r2 := io.LimitReader(r, int64(length))
	buf, err := ioutil.ReadAll(r2)
	if err != nil {
		return int64(n1 + len(buf)), err
	}
	if len(buf) != int(length) {
		return int64(n1 + len(buf)), fmt.Errorf("Expected to read %d bytes, got %d", length, len(buf))
	}
	err = m.UnmarshalBinary(buf)
	if err != nil {
		return 0, err
	}
	return int64(n1 + len(buf)), err
}
913941
func (w *response) ReadFrom(src io.Reader) (int64, error) {
	if rf, ok := w.ResponseWriter.(io.ReaderFrom); ok {
		return rf.ReadFrom(src)
	}
	return 0, ErrNotReaderFrom
}
278710
func (t *TablePropExperimenter) ReadFrom(r io.Reader) (int64, error) {
	var header tableProp

	n, err := encoding.ReadFrom(r, &header, &t.Experimenter, &t.ExpType)
	if err != nil {
		return n, err
	}

	limrd := io.LimitReader(r, int64(header.Len-tablePropLen-8))
	t.Data, err = ioutil.ReadAll(limrd)
	n += int64(len(t.Data))

	if err != nil {
		return n, err
	}

	padding := make([]byte, (header.Len+7)/8*8-header.Len)
	nn, err := encoding.ReadFrom(r, padding)

	return n + nn, err
}
888758
func (h *Header) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &h.Version, &h.Type, &h.Length, &h.Transaction)
}
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
}
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
		}
	}
}
1000682
func (s *SwitchFeatures) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r,
		&s.DatapathID, &s.NumBuffers, &s.NumTables, &s.AuxiliaryID,
		&defaultPad2, &s.Capabilities, &s.Reserved)
}
1306353
func (i *VInt) ReadFrom(r Reader, l int) error {
	var v VInt
	b, err := r.ReadByte()
	if err != nil {
		return errorsp.WithStacks(err)
	}
	v = VInt(b & 0x7f)
	for n := uint(7); b&0x80 != 0; n += 7 {
		if b, err = r.ReadByte(); err != nil {
			if errorsp.Cause(err) == io.EOF {
				return errorsp.WithStacks(io.ErrUnexpectedEOF)
			}
			return errorsp.WithStacks(err)
		}
		v |= VInt(b&0x7f) << n
	}
	*i = v
	return nil
}
143839
func (b *BucketCounter) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &b.PacketCount, &b.ByteCount)
}
1006620
func (d *definition) readFrom(r io.Reader) error {
	err := binary.Read(r, binary.LittleEndian, d)
	if err != nil {
		return err
	}
	magic := reflect.TypeOf(*d).Field(0).Tag.Get("is")
	if !bytes.Equal(d.Magic[:], []byte(magic)) {
		return fmt.Errorf("cram: not a cram file: magic bytes %q", d.Magic)
	}
	return nil
}
191099
func (m *ExperimenterMultipartHeader) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &m.Experimenter, &m.ExpType)
}
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
}
664432
func (q *QueueStats) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &q.Port, &q.Queue, &q.TxBytes,
		&q.TxPackets, &q.TxErrors, &q.DurationSec, &q.DurationNSec)
}
247452
func (p *Ports) ReadFrom(r io.Reader) (n int64, err error) {
	var nn int64

	for err == nil {
		var port Port
		nn, err = port.ReadFrom(r)
		n += nn

		if err == io.EOF {
			err = nil
			return
		}

		*p = append(*p, port)
	}

	return
}