// Binary converts a Graph to a binary OGDL byte stream.
553245
func (g *Graph) Binary() []byte {

	if g == nil {
		return nil
	}

	// Header
	buf := make([]byte, 3)
	buf[0] = 1
	buf[1] = 'G'
	buf[2] = 0

	// The 'root' node is bypassed (it's the 'holder')
	for _, node := range g.Out {
		buf = node.bin(1, buf)
	}

	// Ending null
	buf = append(buf, 0)

	return buf
}
1352439
func CopyBinary(cr bootstrapper.CommandRunner, binary, path string) error {
	f, err := assets.NewFileAsset(path, "/usr/bin", binary, "0755")
	if err != nil {
		return errors.Wrap(err, "new file asset")
	}
	if err := cr.Copy(f); err != nil {
		return errors.Wrapf(err, "copy")
	}
	return nil
}
1025130
func (p LinkADRAnsPayload) MarshalBinary() ([]byte, error) {
	var b byte
	if p.ChannelMaskACK {
		b = b ^ (1 << 0)
	}
	if p.DataRateACK {
		b = b ^ (1 << 1)
	}
	if p.PowerACK {
		b = b ^ (1 << 2)
	}
	return []byte{b}, nil
}
524556
func (m *Category) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}
680271
func (v Version) MarshalBinary() ([]byte, error) {
	if v.Minor > 7 {
		return nil, errors.New("lorawan: max value of Minor is 7")
	}
	return []byte{v.Minor}, nil
}
1039321
func (s Slice) GetBinary() ([]byte, error) {
	if !s.IsBinary() {
		return nil, InvalidTypeError{"Expecting type Binary"}
	}

	h := s.head()
	vpackAssert(h >= 0xc0 && h <= 0xc7)

	lengthSize := uint(h - 0xbf)
	length := readIntegerNonEmpty(s[1:], lengthSize)
	checkOverflow(ValueLength(length))
	return s[1+lengthSize : 1+uint64(lengthSize)+length], nil
}
1239967
func (f *linkFrame) Bytes() (b []byte, err error) {
  buff := new(bytes.Buffer)
  err = f.Encode(buff)
  if err == nil {
    b = buff.Bytes()
  }
  return
}
686674
func doubleNativeFromBinary(buf []byte) (interface{}, []byte, error) {
	if len(buf) < doubleEncodedLength {
		return nil, nil, fmt.Errorf("cannot decode binary double: %s", io.ErrShortBuffer)
	}
	return math.Float64frombits(binary.LittleEndian.Uint64(buf[:doubleEncodedLength])), buf[doubleEncodedLength:], nil
}
1095535
func (pl *Payload) ReadBinary(r io.Reader) error {
	dec := gob.NewDecoder(r)
	return pl.DecodeBinary(dec)
}
433649
func binaryPath(root, binary string) (string, error) {
	subdirs := []string{"sbin", "bin", "libexec"}
	for _, subdir := range subdirs {
		binPath := path.Join(root, subdir, binary)
		if _, err := os.Stat(binPath); err == nil {
			return binPath, nil
		}
	}
	return "", fmt.Errorf("%s not found in any of %s/{%s}",
		binary, root, strings.Join(subdirs, ","))
}
335950
func FromBinaryReader(r io.Reader) *Graph {
	p := newBinParser(r)
	return p.parse()
}
699668
func (c *Websocket) WriteBytesBinary(b []byte) *Websocket {
	if c.checkUnusable("WriteBytesBinary") {
		return c
	}
	return c.WriteMessage(websocket.BinaryMessage, b)
}
465643
func (m *Metric) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}
261744
func Hex(bin binarySerializer) string {
	b := make([]byte, bin.binaryLength())
	bin.binaryPut(b)
	return hexutil.Encode(b)
}
761327
func (b *Builder) addBinary(v []byte) {
	l := uint(len(v))
	b.buf.ReserveSpace(1 + 8 + l)
	b.appendUInt(uint64(l), 0xbf) // data length
	b.buf.Write(v)                // data
}
535793
func BinaryID(v checked.Bytes) ID {
	v.IncRef()
	return &id{data: v}
}
212758
func (t *ToolsMetadata) binary() (version.Binary, error) {
	num, err := version.Parse(t.Version)
	if err != nil {
		return version.Binary{}, errors.Trace(err)
	}
	return version.Binary{
		Number: num,
		Series: t.Release,
		Arch:   t.Arch,
	}, nil
}