stint/endians2

Source   Edit  

Procs

func fromBytes[bits: static int](T: typedesc[StInt[bits]]; x: openArray[byte];
                                 srcEndian: Endianness): T:type {....raises: [],
    noinit, ...gcsafe, inline.}
TODO Unlike the corresponding function in stew/endians that defaults to native endian, this function used to default to big endian - the default has been removed to avoid confusion and runtime surprises. Source   Edit  
func fromBytes[bits: static int](T: typedesc[StUint[bits]];
                                 src: array[bits div 8, byte];
                                 srcEndian: Endianness): T:type {....raises: [],
    noinit, ...gcsafe, inline.}

Read an source bytearray with the specified endianness and convert it to an integer.

TODO Unlike the corresponding function in stew/endians that defaults to native endian, this function used to default to big endian - the default has been removed to avoid confusion and runtime surprises.

Source   Edit  
func fromBytes[bits: static int](T: typedesc[StUint[bits]];
                                 src: openArray[byte]; srcEndian: Endianness): T:type {.
    ...raises: [], noinit, ...gcsafe, inline.}

Read an source bytearray with the specified endianness and convert it to an integer.

TODO Unlike the corresponding function in stew/endians that defaults to native endian, this function used to default to big endian - the default has been removed to avoid confusion and runtime surprises.

Source   Edit  
func fromBytesBE[bits: static int](T: typedesc[StInt[bits]]; x: openArray[byte]): T:type {.
    ...raises: [], noinit, ...gcsafe, inline, ...raises: [], noinit, ...gcsafe, inline.}
Source   Edit  
func fromBytesBE[bits: static int](T: typedesc[StUint[bits]];
                                   src: array[bits div 8, byte]): T:type {.
    ...raises: [], noinit, ...gcsafe, inline.}

Read big endian bytes and convert to an integer. At runtime, src must contain at least sizeof(T) bytes.

TODO Contrary to docs and the corresponding stew/endians2 function, src is actually padded when short - this may change in the future to match stew where it panics instead.

Source   Edit  
func fromBytesBE[bits: static int](T: typedesc[StUint[bits]];
                                   src: openArray[byte]): T:type {....raises: [],
    noinit, ...gcsafe, inline.}

Read big endian bytes and convert to an integer. At runtime, src must contain at least sizeof(T) bytes.

TODO Contrary to docs and the corresponding stew/endians2 function, src is actually padded when short - this may change in the future to match stew where it panics instead.

Source   Edit  
func fromBytesLE[bits: static int](T: typedesc[StInt[bits]]; x: openArray[byte]): T:type {.
    ...raises: [], noinit, ...gcsafe, inline.}
Source   Edit  
func fromBytesLE[bits: static int](T: typedesc[StUint[bits]];
                                   src: array[bits div 8, byte]): T:type {.
    ...raises: [], noinit, ...gcsafe, inline.}
Source   Edit  
func fromBytesLE[bits: static int](T: typedesc[StUint[bits]];
                                   src: openArray[byte]): T:type {....raises: [],
    noinit, ...gcsafe, inline.}

Read little endian bytes and convert to an integer. At runtime, src must contain at least sizeof(T) bytes.

TODO Contrary to docs and the corresponding stew/endians2 function, src is actually padded when short - this may change in the future to match stew where it panics instead.

Source   Edit  
func toBytes[bits: static int](x: StInt[bits]; endian: Endianness): array[
    bits div 8, byte] {....raises: [], noinit, ...gcsafe, inline.}
TODO Unlike the corresponding function in stew/endians that defaults to native endian, this function used to default to big endian - the default has been removed to avoid confusion and runtime surprises. Source   Edit  
func toBytes[bits: static int](x: StUint[bits]; endian: Endianness): array[
    bits div 8, byte] {....raises: [], noinit, ...gcsafe, inline.}

Encode src to a byte array using the given byte order.

TODO Unlike the corresponding function in stew/endians that defaults to native endian, this function used to default to big endian - the default has been removed to avoid confusion and runtime surprises.

Source   Edit  
func toBytesBE[bits: static int](src: StInt[bits]): array[bits div 8, byte] {.
    ...raises: [], noinit, ...gcsafe, inline.}
Source   Edit  
func toBytesBE[bits: static int](src: StUint[bits]): array[bits div 8, byte] {.
    ...raises: [], noinit, ...gcsafe, inline.}
Encode src to a byte array using big-endian byte order. Source   Edit  
func toBytesLE[bits: static int](src: StInt[bits]): array[bits div 8, byte] {.
    ...raises: [], noinit, ...gcsafe, inline.}
Source   Edit  
func toBytesLE[bits: static int](src: StUint[bits]): array[bits div 8, byte] {.
    ...raises: [], noinit, ...gcsafe, inline.}
Encode src to a byte array using little-endian byte order. Source   Edit