// ReadMessage attempts to read a message object from the given io.Reader, parse
// it, and return a Message struct representing it
773754
func ReadMessage(reader io.Reader) (*Message, error) {
	r := bufio.NewReader(reader)
	return bufioReadMessage(r)
}
917776
func (v *Xception) GetMessage() (o string) {
	if v != nil && v.Message != nil {
		return *v.Message
	}

	return
}
455621
func readMessages(r io.Reader, p []byte) error {
	for len(p) > 0 {
		n, err := r.Read(p)
		p = p[n:]
		if err != nil {
			return err
		}
	}
	return nil
}
593713
func (p *Buffer) DecodeMessage(pb Message) error {
	enc, err := p.DecodeRawBytes(false)
	if err != nil {
		return err
	}
	return NewBuffer(enc).Unmarshal(pb)
}
559529
func ReadMessage(reader io.Reader) (m []byte, err error) {
	var length int32
	err = binary.Read(reader, binary.LittleEndian, &length)
	if err == io.EOF {
		return nil, io.EOF
	}
	if err != nil {
		return nil, fmt.Errorf("Failed to read message length: %v", err)
	}
	if length == int32(MessageControlEOF) {
		return nil, io.EOF
	}
	if length == 0 {
		return
	}
	m = make([]byte, length)
	var n int
	n, err = io.ReadFull(reader, m)
	if err == io.EOF {
		return nil, fmt.Errorf("Unexpected EOF when reading message size %d, but actual only %d.", length, n)
	}
	if err != nil {
		return nil, fmt.Errorf("Failed to read message content size %d, but read only %d: %v", length, n, err)
	}
	return m, nil
}
844695
func (s *UnprocessedTraceSegment) SetMessage(v string) *UnprocessedTraceSegment {
	s.Message = &v
	return s
}
109937
func (s *BatchResultErrorEntry) SetMessage(v string) *BatchResultErrorEntry {
	s.Message = &v
	return s
}
1233834
func ReadMessage(r io.Reader, msg proto.Message) error {
	return readProtoMsg(r, msg, maxMsgSize)
}
1240310
func (r *ReadContext) ReadMessage(msg proto.Message) error {
	savior.Debugf("wire.ReadContext: Reading message at %d", r.offset)

	length, err := binary.ReadUvarint(r.countingReader)
	if err != nil {
		return errors.WithStack(err)
	}

	msgBuf := r.protoBuffer.Bytes()
	if cap(msgBuf) < int(length) {
		msgBuf = make([]byte, nextPowerOf2(int(length)))
	}

	_, err = io.ReadFull(r.countingReader, msgBuf[:length])
	if err != nil {
		return errors.WithStack(err)
	}
	r.protoBuffer.SetBuf(msgBuf[:length])

	msg.Reset()

	err = r.protoBuffer.Unmarshal(msg)
	if err != nil {
		return errors.WithStack(err)
	}

	if DebugWire {
		fmt.Printf(">> %s %+v\n", reflect.TypeOf(msg).Elem().Name(), msg)
	}

	return nil
}
830729
func (s *PhaseContext) SetMessage(v string) *PhaseContext {
	s.Message = &v
	return s
}
1027323
func (s *EntityRecognizerProperties) SetMessage(v string) *EntityRecognizerProperties {
	s.Message = &v
	return s
}
1213600
func (s *EnvironmentInfoDescription) SetMessage(v string) *EnvironmentInfoDescription {
	s.Message = &v
	return s
}
1071864
func (s *GetBatchPredictionOutput) SetMessage(v string) *GetBatchPredictionOutput {
	s.Message = &v
	return s
}
924489
func (p *Peer) readMessage(encoding wire.MessageEncoding) (wire.Message, []byte, error) {
	n, msg, buf, err := wire.ReadMessageWithEncodingN(p.conn,
		p.ProtocolVersion(), p.cfg.ChainParams.Net, encoding)
	atomic.AddUint64(&p.bytesReceived, uint64(n))
	if p.cfg.Listeners.OnRead != nil {
		p.cfg.Listeners.OnRead(p, n, msg, err)
	}
	if err != nil {
		return nil, nil, err
	}

	// Use closures to log expensive operations so they are only run when
	// the logging level requires it.
	log.Debugf("%v", newLogClosure(func() string {
		// Debug summary of message.
		summary := messageSummary(msg)
		if len(summary) > 0 {
			summary = " (" + summary + ")"
		}
		return fmt.Sprintf("Received %v%s from %s",
			msg.Command(), summary, p)
	}))
	log.Tracef("%v", newLogClosure(func() string {
		return spew.Sdump(msg)
	}))
	log.Tracef("%v", newLogClosure(func() string {
		return spew.Sdump(buf)
	}))

	return msg, buf, nil
}
1032706
func (t *MockSocket) ReadMessage() (int, []byte, error) {
	message, isOpen := <-t.receivedMessages
	if !isOpen {
		return 0, nil, errors.New("socket closed by test case")
	}
	return 1, message, nil
}
1325784
func readMessage(r *http.Request, msg proto.Message) *protocolError {
	format, err := FormatFromContentType(r.Header.Get(headerContentType))
	if err != nil {
		// Spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.16
		return errorf(http.StatusUnsupportedMediaType, "Content-Type header: %s", err)
	}

	buf, err := ioutil.ReadAll(r.Body)
	if err != nil {
		return errorf(http.StatusBadRequest, "could not read body: %s", err)
	}
	switch format {
	// Do not redefine "err" below.

	case FormatJSONPB:
		err = jsonpb.Unmarshal(bytes.NewBuffer(buf), msg)

	case FormatText:
		err = proto.UnmarshalText(string(buf), msg)

	case FormatBinary:
		err = proto.Unmarshal(buf, msg)

	default:
		panic(fmt.Errorf("impossible: invalid format %v", format))
	}
	if err != nil {
		return errorf(http.StatusBadRequest, "could not decode body: %s", err)
	}
	return nil
}
402163
func ReadMessage(r io.Reader, pver uint32) (Message, error) {
	// First, we'll read out the first two bytes of the message so we can
	// create the proper empty message.
	var mType [2]byte
	if _, err := io.ReadFull(r, mType[:]); err != nil {
		return nil, err
	}

	msgType := MessageType(binary.BigEndian.Uint16(mType[:]))

	// Now that we know the target message type, we can create the proper
	// empty message type and decode the message into it.
	msg, err := makeEmptyMessage(msgType)
	if err != nil {
		return nil, err
	}
	if err := msg.Decode(r, pver); err != nil {
		return nil, err
	}

	return msg, nil
}