libp2p/stream/lpstream

    Dark Mode
Search:
Group by:
  Source   Edit

Length Prefixed stream implementation

Types

Direction {.pure.} = enum
  In, Out
  Source   Edit
LPStream = ref object of RootObj
  closeEvent*: AsyncEvent
  isClosed*: bool
  isEof*: bool
  objName*: string
  oid*: Oid
  dir*: Direction
  closedWithEOF: bool
  Source   Edit
LPStreamError = object of LPError
  Source   Edit
LPStreamIncorrectDefect = object of Defect
  Source   Edit
LPStreamReadError = object of LPStreamError
  par*: ref CatchableError
  Source   Edit
LPStreamWriteError = object of LPStreamError
  par*: ref CatchableError
  Source   Edit
MaxSizeError = object of LPStreamError
  Source   Edit
StreamTracker = ref object of TrackerBase
  opened*: uint64
  closed*: uint64
  Source   Edit

Consts

Eof = []
  Source   Edit
LPStreamTrackerName = "LPStream"
  Source   Edit

Procs

proc closeWithEOF(s: LPStream): Future[void] {.public(), stackTrace: false,
    ...gcsafe, raises: [Defect], raises: [Defect], tags: [RootEffect].}
  Source   Edit
proc join(s: LPStream): Future[void] {.public, ...raises: [Defect], tags: [].}
Wait for the stream to be closed   Source   Edit
proc newLPStreamClosedError(): ref LPStreamClosedError {....raises: [Defect],
    tags: [].}
  Source   Edit
proc newLPStreamEOFError(): ref LPStreamEOFError {....raises: [Defect], tags: [].}
  Source   Edit
proc newLPStreamIncompleteError(): ref LPStreamIncompleteError {.
    ...raises: [Defect], tags: [].}
  Source   Edit
proc newLPStreamIncorrectDefect(m: string): ref LPStreamIncorrectDefect {.
    ...raises: [Defect], tags: [].}
  Source   Edit
proc newLPStreamLimitError(): ref LPStreamLimitError {....raises: [Defect],
    tags: [].}
  Source   Edit
proc newLPStreamReadError(msg: string): ref LPStreamReadError {.
    ...raises: [Defect], tags: [].}
  Source   Edit
proc newLPStreamReadError(p: ref CatchableError): ref LPStreamReadError {.
    ...raises: [Defect], tags: [].}
  Source   Edit
proc newLPStreamWriteError(p: ref CatchableError): ref LPStreamWriteError {.
    ...raises: [Defect], tags: [].}
  Source   Edit
proc readExactly(s: LPStream; pbytes: pointer; nbytes: int): Future[void] {.
    public(), stackTrace: false, ...gcsafe, raises: [Defect], raises: [Defect],
    tags: [RootEffect].}
  Source   Edit
proc readLine(s: LPStream; limit = 0; sep = "\r\n"): Future[string] {.public(),
    stackTrace: false, ...gcsafe, raises: [Defect], raises: [Defect],
    tags: [RootEffect].}
  Source   Edit
proc readLp(s: LPStream; maxSize: int): Future[seq[byte]] {....gcsafe, public(),
    stackTrace: false, ...gcsafe, raises: [Defect], raises: [Defect],
    tags: [RootEffect].}
  Source   Edit
proc readVarint(conn: LPStream): Future[uint64] {....gcsafe, public(),
    stackTrace: false, ...gcsafe, raises: [Defect], raises: [Defect],
    tags: [RootEffect].}
  Source   Edit
func shortLog(s: LPStream): auto {....raises: [Defect], tags: [].}
  Source   Edit
proc write(s: LPStream; msg: string): Future[void] {.public, ...raises: [Defect],
    tags: [].}
  Source   Edit
proc writeLp(s: LPStream; msg: openArray[byte]): Future[void] {.public,
    ...raises: [Defect], tags: [].}
Write msg with a varint-encoded length prefix   Source   Edit
proc writeLp(s: LPStream; msg: string): Future[void] {.public, ...raises: [Defect],
    tags: [].}
  Source   Edit

Methods

method atEof(s: LPStream): bool {.base, public, ...raises: [Defect], tags: [].}
  Source   Edit
method close(s: LPStream): Future[void] {.base, public(), stackTrace: false,
    ...gcsafe, raises: [Defect], raises: [Defect], tags: [RootEffect].}
  Source   Edit
method closed(s: LPStream): bool {.base, public, ...raises: [Defect], tags: [].}
  Source   Edit
method closeImpl(s: LPStream): Future[void] {.base, stackTrace: false, ...gcsafe,
    raises: [Defect], raises: [Defect], tags: [RootEffect].}
  Source   Edit
method initStream(s: LPStream) {.base, ...raises: [Defect], tags: [TimeEffect].}
  Source   Edit
method readOnce(s: LPStream; pbytes: pointer; nbytes: int): Future[int] {.base,
    public(), stackTrace: false, ...gcsafe, raises: [Defect], raises: [Defect],
    tags: [RootEffect].}
  Source   Edit
method write(s: LPStream; msg: seq[byte]): Future[void] {.base, public,
    ...raises: [Defect], tags: [].}
  Source   Edit

Templates

template formatItIMPL(it: LPStream): auto
  Source   Edit