bio

Bytes utils for Nim.

Pure Nim score 15/100 · tests present · no docs generated

Summary

Latest Version Unknown
License Apache-2.0
CI Status Failing
Downloads 0
Last Indexed 2026-07-21 05:24

Installation

nimble install bio
choosenim install bio
git clone https://github.com/xzeshen/bio

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
bio - - - - - - -

Source

Repository https://github.com/xzeshen/bio
Homepage https://github.com/xzeshen/bio
Registry Source nimble_official

README

API: bio

import bio

proc toByteSeq

Converts a string to the corresponding byte sequence.

proc toByteSeq(str: string): seq[byte] {.inline.}

proc fromByteSeq

Converts a byte sequence to the corresponding string.

proc fromByteSeq(arr: openArray[byte]): string {.inline.}

proc serialize

Serializes uint64|int64 to byte array in endians order.

proc serialize(number: uint64 | uint64; endians: Endianness): array[8, byte] {.inline.}

proc serialize

Serializes uint32|int32 to byte array.in endians order.

proc serialize(number: uint32 | uint32; endians: Endianness): array[4, byte] {.inline.}

proc serialize

Serializes uint16|int16 to byte array.in endians order.

proc serialize(number: uint16 | uint16; endians: Endianness): array[2, byte] {.inline.}

template offset

Gets pointer p of offset n.

template offset(p: pointer; n: int): pointer

template canReadNBytes

Decides whether can read length bytes.

template canReadNBytes(stream: StringStream; length: Natural): bool

template canReadHowManyBytes

Can read how many bytes.

template canReadHowManyBytes(stream: StringStream): int

proc readBEInt64

Reads int64 in big endians order.

proc readBEInt64(strm: Stream): int64 {.inline, raises: [Defect, IOError, OSError], tags: [ReadIOEffect].}

proc readBEInt32

Reads int32 in big endians order.

proc readBEInt32(strm: Stream): int32 {.inline, raises: [Defect, IOError, OSError], tags: [ReadIOEffect].}

proc readBEInt16

Reads int16 in big endians order.

proc readBEInt16(strm: Stream): int16 {.inline, raises: [Defect, IOError, OSError], tags: [ReadIOEffect].}

proc readBEInt8

Reads int8 in big endians order.

proc readBEInt8(strm: Stream): int8 {.inline, raises: [Defect, IOError, OSError], tags: [ReadIOEffect].}

proc readLEInt64

Reads int64 in small endians order.

proc readLEInt64(strm: Stream): int64 {.inline, raises: [Defect, IOError, OSError], tags: [ReadIOEffect].}

proc readLEInt32

Reads int32 in small endians order.

proc readLEInt32(strm: Stream): int32 {.inline, raises: [Defect, IOError, OSError], tags: [ReadIOEffect].}

proc readLEInt16

Reads int16 in small endians order.

proc readLEInt16(strm: Stream): int16 {.inline, raises: [Defect, IOError, OSError], tags: [ReadIOEffect].}

proc readLEInt8

Reads int8 in small endians order.

proc readLEInt8(strm: Stream): int8 {.inline, raises: [Defect, IOError, OSError], tags: [ReadIOEffect].}

proc readBEUint64

Reads uint64 in big endians order.

proc readBEUint64(strm: Stream): uint64 {.inline, raises: [Defect, IOError, OSError], tags: [ReadIOEffect].}

proc readBEUint32

Reads uint32 in big endians order.

proc readBEUint32(strm: Stream): uint32 {.inline, raises: [Defect, IOError, OSError], tags: [ReadIOEffect].}

proc readBEUint16

Reads uint16 in big endians order.

proc readBEUint16(strm: Stream): uint16 {.inline, raises: [Defect, IOError, OSError], tags: [ReadIOEffect].}

proc readBEUint8

Reads uint8 in big endians order.

proc readBEUint8(strm: Stream): uint8 {.inline, raises: [Defect, IOError, OSError], tags: [ReadIOEffect].}

proc readLEUint64

Reads uint64 in small endians order.

proc readLEUint64(strm: Stream): uint64 {.inline, raises: [Defect, IOError, OSError], tags: [ReadIOEffect].}

proc readLEUint32

Reads uint32 in small endians order.

proc readLEUint32(strm: Stream): uint32 {.inline, raises: [Defect, IOError, OSError], tags: [ReadIOEffect].}

proc readLEUint16

Reads uint16 in small endians order.

proc readLEUint16(strm: Stream): uint16 {.inline, raises: [Defect, IOError, OSError], tags: [ReadIOEffect].}

proc readLEUint8

Reads uint8 in small endians order.

proc readLEUint8(strm: Stream): uint8 {.inline, raises: [Defect, IOError, OSError], tags: [ReadIOEffect].}