src/modernnet/io

Source   Edit  

Types

RawPacket = object
  id*: int
  buf*: Buffer
Source   Edit  
Result[T; E] = object
  case isOk*: bool
  of true:
    when T isnot void:
      ok*: T
  of false:
    when E isnot void:
      err*: E
Source   Edit  

Procs

func readRawPacket(data: openArray[byte]): Result[
    tuple[packet: RawPacket, bytesRead: int], int] {.
    ...raises: [MnPacketParsingError], tags: [], forbids: [].}
Reads a packet from the given byte sequence and returns a RawPacket that has the ID and the buffer. Returns an error if the packet is too short. Source   Edit  
func readVar[R: int32 | int64](data: openArray[byte]): Result[
    tuple[num: R, bytesRead: int], int]
Reads a VarInt or a VarLong from the given byte sequence Source   Edit