// FromBytes decodes bytes into a opentracing.SpanContext and transport.Request
483170
func FromBytes(tracer opentracing.Tracer, request []byte) (opentracing.SpanContext, *transport.Request, error) {
	if len(request) <= 1 {
		return nil, nil, errors.New("cannot deserialize empty request")
	}

	// check valid thrift serialization byte
	if request[0] != 0 {
		return nil, nil,
			fmt.Errorf(
				"unsupported YARPC serialization version '%v' found during deserialization",
				request[0])
	}

	reader := bytes.NewReader(request[1:])
	wireValue, err := protocol.Binary.Decode(reader, wire.TStruct)
	if err != nil {
		return nil, nil, err
	}

	var rpc internal.RPC
	if err = rpc.FromWire(wireValue); err != nil {
		return nil, nil, err
	}

	req := transport.Request{
		Caller:    rpc.CallerName,
		Service:   rpc.ServiceName,
		Encoding:  transport.Encoding(rpc.Encoding),
		Procedure: rpc.Procedure,
		Headers:   transport.HeadersFromMap(rpc.Headers),
		Body:      bytes.NewBuffer(rpc.Body),
	}

	if rpc.ShardKey != nil {
		req.ShardKey = *rpc.ShardKey
	}
	if rpc.RoutingKey != nil {
		req.RoutingKey = *rpc.RoutingKey
	}
	if rpc.RoutingDelegate != nil {
		req.RoutingDelegate = *rpc.RoutingDelegate
	}

	spanContext, err := spanContextFromBytes(tracer, rpc.SpanContext)
	if err != nil {
		return nil, nil, err
	}

	return spanContext, &req, nil
}
154575
func FromBytes(b []byte) *SMTPMessage {
	msg := &SMTPMessage{}
	var headerDone bool
	for _, l := range strings.Split(string(b), "\n") {
		if !headerDone {
			if strings.HasPrefix(l, "HELO:<") {
				l = strings.TrimPrefix(l, "HELO:<")
				l = strings.TrimSuffix(l, ">\r")
				msg.Helo = l
				continue
			}
			if strings.HasPrefix(l, "FROM:<") {
				l = strings.TrimPrefix(l, "FROM:<")
				l = strings.TrimSuffix(l, ">\r")
				msg.From = l
				continue
			}
			if strings.HasPrefix(l, "TO:<") {
				l = strings.TrimPrefix(l, "TO:<")
				l = strings.TrimSuffix(l, ">\r")
				msg.To = append(msg.To, l)
				continue
			}
			if strings.TrimSpace(l) == "" {
				headerDone = true
				continue
			}
		}
		msg.Data += l + "\n"
	}
	return msg
}
1007230
func readBytes(r io.Reader) ([]byte, error) {
	length, err := readInt32(r)
	if err != nil {
		return nil, err
	}
	buf := make([]byte, length)
	_, err = io.ReadFull(r, buf)
	if err != nil {
		return nil, err
	}
	return buf, nil
}
1054833
func (d Data) GetBytes(key string) []byte {
	return []byte(d.Get(key))
}
684601
func FromJSON(jsonBytes []byte) ([]byte, error) {
	var j EncodedCaddyfile
	var result string

	err := json.Unmarshal(jsonBytes, &j)
	if err != nil {
		return nil, err
	}

	for sbPos, sb := range j {
		if sbPos > 0 {
			result += "\n\n"
		}
		for i, key := range sb.Keys {
			if i > 0 {
				result += ", "
			}
			//result += standardizeScheme(key)
			result += key
		}
		result += jsonToText(sb.Body, 1)
	}

	return []byte(result), nil
}
345978
func FromUint64(data [8]byte) uint64 {
	ui64 := binary.BigEndian.Uint64(data[:])
	return ui64
}
153102
func (r *Encoder) EncodeBytes(b []byte) error {
	if len(b) < STR_FIXED_COUNT {
		_, err := r.w.Write([]byte{byte(STR_FIXED_START + len(b))})
		if err != nil {
			return err
		}
		_, err = r.w.Write(b)
		return err
	}

	prefix := []byte(fmt.Sprintf("%d:", len(b)))

	_, err := r.w.Write(prefix)
	if err != nil {
		return err
	}

	_, err = r.w.Write(b)
	return err
}
1106559
func FromBytes(b []byte) *Graph {
	p := NewParser(bytes.NewBuffer(b))
	p.Ogdl()
	return p.Graph()
}
1328532
func FromBytes(input []byte) (u UUID, err error) {
	err = u.UnmarshalBinary(input)
	return
}
226680
func (r *Service) GetBytes(key string) ([]byte, error) {
	c := r.pool.Get()
	defer c.Close()
	if err := c.Err(); err != nil {
		return nil, err
	}

	redisVal, err := c.Do("GET", r.Config.Prefix+key)

	if err != nil {
		return nil, err
	}
	if redisVal == nil {
		return nil, ErrKeyNotFound.Format(key)
	}

	return redis.Bytes(redisVal, err)
}
769710
func (s *SearchService) From(from int) *SearchService {
	s.searchSource = s.searchSource.From(from)
	return s
}
123078
func EncodeBytes(data []byte) string {
	mt := http.DetectContentType(data)
	// http.DetectContentType may add spurious spaces between ; and a parameter.
	// The canonical way is to not have them.
	cleanedMt := strings.Replace(mt, "; ", ";", -1)

	return New(data, cleanedMt).String()
}
551475
func (r *Request) FromValues(values Values, data []byte) error {
	signatureBytes, err := hexutil.Decode(values.Get("signature"))
	if err != nil {
		r.Signature = nil
	} else {
		if len(signatureBytes) != signatureLength {
			return NewError(ErrInvalidSignature, "Incorrect signature length")
		}
		r.Signature = new(Signature)
		copy(r.Signature[:], signatureBytes)
	}
	err = r.Update.FromValues(values, data)
	if err != nil {
		return err
	}
	r.idAddr = r.Addr()
	return err
}
25144
func fromBytes(b []byte) *orcapb.LoadReport {
	ret := new(orcapb.LoadReport)
	if err := proto.Unmarshal(b, ret); err != nil {
		grpclog.Warningf("orca: failed to unmarshal load report: %v", err)
		return nil
	}
	return ret
}
385650
func (priv *PrivateKey) FromBytes(b []byte) (err error) {
	if len(b) != 32 {
		return fmt.Errorf("Invalid private key bytes length %d, expected 32.", len(b))
	}

	priv.D = new(big.Int).SetBytes(b)

	/* Derive public key from private key */
	priv.derive()

	return nil
}
570348
func (ps *PaymentStatus) FromBytes(status []byte) error {
	if len(status) != 1 {
		return errors.New("payment status is empty")
	}

	switch PaymentStatus(status[0]) {
	case StatusGrounded, StatusInFlight, StatusCompleted:
		*ps = PaymentStatus(status[0])
	default:
		return errors.New("unknown payment status")
	}

	return nil
}
965278
func (fd *FileData) GetBytes(ctx context.Context,
	startOff, endOff Int64Offset) (data []byte, err error) {
	bytes, err := fd.getByteSlicesInOffsetRange(ctx, startOff, endOff, false)
	if err != nil {
		return nil, err
	}

	bufSize := 0
	for _, b := range bytes {
		bufSize += len(b)
	}
	data = make([]byte, bufSize)
	currLen := 0
	for _, b := range bytes {
		copy(data[currLen:currLen+len(b)], b)
		currLen += len(b)
	}

	return data, nil
}