Module views

Types

View*[T] = object
  data*: pointer
  size*: int
  Source Edit
ConstView*[T] = object
  data*: pointer
  size*: int
  Source Edit
SomeView*[T] = View[T] | ConstView[T]
  Source Edit
ByteView* = View[byte]
  Source Edit

Procs

proc emptyView*[T](): View[T]
  Source Edit
proc singleItemView*[T](item: var T): View[T]
  Source Edit
proc seqView*[T](s: var seq[T]): View[T]
  Source Edit
proc stringView*(s: var string): View[byte]
  Source Edit
proc addrView*(s: cstring; size: int): View[byte]
  Source Edit
proc asView*(s: var string): auto
  Source Edit
proc asUnsafeView*(s: string): auto
  Source Edit
proc asView*(s: var seq): auto
  Source Edit
proc isNil*(v: View): bool
  Source Edit
proc len*(v: View): int
  Source Edit
proc len*(v: ConstView): int
  Source Edit
proc asPointer*[T](v: SomeView[T]): ptr T
  Source Edit
proc `[]`*[T](v: ConstView[T]; i: int): T
  Source Edit
proc `[]`*[T](v: View[T]; i: int): var T
  Source Edit
proc `[]=`*[T](v: View[T]; i: int; val: T)
  Source Edit
proc slice*[T](v: SomeView[T]; start: int; size: int): SomeView[T]
  Source Edit
proc slice*[T](v: SomeView[T]; start: int): SomeView[T]
  Source Edit
proc copyFrom*[T](dst: View[T]; src: SomeView[T])
  Source Edit
proc copyTo*[T](src: SomeView[T]; dst: View[T])
  Source Edit
proc copyAsSeq*[T](src: ConstView[T]): seq[T]
  Source Edit
proc copyAsString*(src: SomeView[byte]): string
  Source Edit
proc copyAs*[R, T](src: SomeView[R]; t: typedesc[T]): T
  Source Edit
proc `$`*[T](v: SomeView[T]): string
  Source Edit
proc clearIfReferenceType*[T](view: SomeView[T])
Clears view if it contains GC type   Source Edit
proc alignedStringView*(s: var string; align = 16): ByteView
Return view into string s. Align it to align bytes if needed.   Source Edit

Iterators

iterator items*[T](src: SomeView[T]): T
  Source Edit

Converters

converter viewToConstView*[T](v: View[T]): ConstView[T]
  Source Edit

Templates

template asByteView*(s): ByteView
  Source Edit