update docs for ma-pb-repeated-field

This commit is contained in:
= 2023-04-13 10:59:10 +00:00
parent c8280ea5c8
commit 312b14ce35
5 changed files with 5047 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,941 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- This file is generated by Nim. -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Favicon -->
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
<!-- Google fonts -->
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
<!-- CSS -->
<title>libp2p/protobuf/minprotobuf</title>
<link rel="stylesheet" type="text/css" href="../../nimdoc.out.css">
<script type="text/javascript" src="../../dochack.js"></script>
<script type="text/javascript">
function main() {
var pragmaDots = document.getElementsByClassName("pragmadots");
for (var i = 0; i < pragmaDots.length; i++) {
pragmaDots[i].onclick = function(event) {
// Hide tease
event.target.parentNode.style.display = "none";
// Show actual
event.target.parentNode.nextElementSibling.style.display = "inline";
}
}
function switchTheme(e) {
if (e.target.checked) {
document.documentElement.setAttribute('data-theme', 'dark');
localStorage.setItem('theme', 'dark');
} else {
document.documentElement.setAttribute('data-theme', 'light');
localStorage.setItem('theme', 'light');
}
}
const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');
if (toggleSwitch !== null) {
toggleSwitch.addEventListener('change', switchTheme, false);
}
var currentTheme = localStorage.getItem('theme');
if (!currentTheme && window.matchMedia('(prefers-color-scheme: dark)').matches) {
currentTheme = 'dark';
}
if (currentTheme) {
document.documentElement.setAttribute('data-theme', currentTheme);
if (currentTheme === 'dark' && toggleSwitch !== null) {
toggleSwitch.checked = true;
}
}
}
window.addEventListener('DOMContentLoaded', main);
</script>
</head>
<body>
<div class="document" id="documentId">
<div class="container">
<h1 class="title">libp2p/protobuf/minprotobuf</h1>
<div class="row">
<div class="three columns">
<div class="theme-switch-wrapper">
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox" />
<div class="slider round"></div>
</label>
&nbsp;&nbsp;&nbsp; <em>Dark Mode</em>
</div>
<div id="global-links">
<ul class="simple">
<li>
<a href="../../theindex.html">Index</a>
</li>
</ul>
</div>
<div id="searchInputDiv">
Search: <input type="text" id="searchInput"
onkeyup="search()" />
</div>
<div>
Group by:
<select onchange="groupBy(this.value)">
<option value="section">Section</option>
<option value="type">Type</option>
</select>
</div>
<script type="text/javascript">
function main2() {
// Create the slider
var firstSlider = document.getElementsByClassName("theme-switch-wrapper")[0];
var newSlider = document.createRange().createContextualFragment(`
<div class="theme-switch-wrapper">
<label class="theme-switch" for="internalcheckbox">
<input type="checkbox" id="internalcheckbox">
<div class="slider round"></div>
</label>
&nbsp;&nbsp;&nbsp; <em>Internal</em>
</div>
`);
var sliderInst = firstSlider.after(newSlider);
// Restore slider state from storage
var currentMode = localStorage.getItem('privateMode');
if (currentMode == "private") {
document.getElementById("internalcheckbox").checked = true;
} else {
hidePrivateProcs();
}
document.getElementById("internalcheckbox").onclick = togglePrivateProcs;
}
function hidePrivateProcs() {
var toHide = document.getElementsByClassName("tohide");
for (var i = 0; i < toHide.length; i++) {
var pragmas = toHide[i].querySelectorAll("span.Identifier");
var public = false;
for (var z = 0; z < pragmas.length; z++) {
if (pragmas[z].innerText == "public") {
public = true;
break;
}
}
if (public == false) {
toHide[i].style.display = "none";
toHide[i].classList.add("hidden");
links = document.querySelectorAll("a[href='#" + encodeURIComponent(toHide[i].id) + "']");
for (var y = 0; y < links.length; y++) {
links[y].parentNode.style.display = "none";
links[y].parentNode.classList.add("hidden");
}
}
}
// TOC
var nestedSections = document.getElementsByClassName("nested-toc-section");
for (var i = 0; i < nestedSections.length; i++) {
if (nestedSections[i].querySelectorAll("li:not(.hidden)").length == 0) {
nestedSections[i].style.display = "none";
nestedSections[i].classList.add("hidden");
}
}
var sections = document.getElementsByClassName("simple-toc-section");
for (var i = 0; i < sections.length; i++) {
if (sections[i].querySelectorAll(".nested-toc-section:not(.hidden)").length == 0) {
sections[i].parentNode.style.display = "none";
sections[i].parentNode.classList.add("hidden");
}
}
// Sections
var sections = document.getElementsByClassName("section");
for (var i = 0; i < sections.length; i++) {
if (sections[i].querySelectorAll(".item > div").length == 0) continue;
if (sections[i].querySelectorAll(".item > div:not(.hidden)").length == 0) {
sections[i].style.display = "none";
sections[i].classList.add("hidden");
}
}
}
function showPrivateProcs() {
var toHide = Array.from(document.getElementsByClassName("hidden"));
for (var i = 0; i < toHide.length; i++) {
toHide[i].style.display = "";
toHide[i].classList.remove("hidden");
}
}
function togglePrivateProcs() {
if (document.getElementById("internalcheckbox").checked) {
localStorage.setItem('privateMode', 'private');
showPrivateProcs();
} else {
localStorage.setItem('privateMode', 'public');
hidePrivateProcs();
}
}
window.addEventListener("DOMContentLoaded", main2);
</script>
<ul class="simple simple-toc" id="toc-list">
<li>
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
<ul class="simple simple-toc-section">
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#7" id="57">Types</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#ProtoBuffer"
title="ProtoBuffer = object
options: set[ProtoFlags]
buffer*: seq[byte]
offset*: int
length*: int
maxSize*: uint">ProtoBuffer</a></li>
<li><a class="reference" href="#ProtoError"
title="ProtoError {.pure.} = enum
VarintDecode, MessageIncomplete, BufferOverflow, MessageTooBig, BadWireType,
IncorrectBlob, RequiredFieldMissing">ProtoError</a></li>
<li><a class="reference" href="#ProtoField"
title="ProtoField = object
index*: int
case kind*: ProtoFieldKind
of Varint:
vint*: uint64
of Fixed64:
vfloat64*: float64
of Length:
vbuffer*: seq[byte]
of Fixed32:
vfloat32*: float32
of StartGroup, EndGroup:
nil">ProtoField</a></li>
<li><a class="reference" href="#ProtoFieldKind"
title="ProtoFieldKind = enum
Varint, Fixed64, Length, StartGroup, EndGroup, Fixed32">ProtoFieldKind</a></li>
<li><a class="reference" href="#ProtoFlags"
title="ProtoFlags = enum
WithVarintLength, WithUint32BeLength, WithUint32LeLength">ProtoFlags</a></li>
<li><a class="reference" href="#ProtoHeader"
title="ProtoHeader = object
wire*: ProtoFieldKind
index*: uint64">ProtoHeader</a></li>
<li><a class="reference" href="#ProtoResult"
title="ProtoResult[T] = Result[T, ProtoError]">ProtoResult</a></li>
<li><a class="reference" href="#ProtoScalar"
title="ProtoScalar = uint | uint32 | uint64 | zint | zint32 | zint64 | hint | hint32 |
hint64 |
float32 |
float64">ProtoScalar</a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#10" id="60">Consts</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#SupportedWireTypes"
title="SupportedWireTypes = {0, 1, 2, 5}">SupportedWireTypes</a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#12" id="62">Procs</a>
<ul class="simple simple-toc-section">
<ul class="simple nested-toc-section">finish
<li><a class="reference" href="#finish%2CProtoBuffer"
title="finish(pb: var ProtoBuffer)">finish(pb: var ProtoBuffer)</a></li>
</ul>
<ul class="simple nested-toc-section">getField
<li><a class="reference" href="#getField%2CProtoBuffer%2Cint%2CProtoBuffer"
title="getField(pb: ProtoBuffer; field: int; output: var ProtoBuffer): ProtoResult[bool]">getField(pb: ProtoBuffer; field: int; output: var ProtoBuffer): ProtoResult[bool]</a></li>
<li><a class="reference" href="#getField%2CProtoBuffer%2Cint%2CopenArray%5BT%5D%2Cint"
title="getField[T: byte | char](data: ProtoBuffer; field: int;
output: var openArray[T]; outlen: var int): ProtoResult[
bool]">getField[T: byte | char](data: ProtoBuffer; field: int;
output: var openArray[T]; outlen: var int): ProtoResult[
bool]</a></li>
<li><a class="reference" href="#getField%2CProtoBuffer%2Cint%2CT"
title="getField[T: ProtoScalar](data: ProtoBuffer; field: int; output: var T): ProtoResult[
bool]">getField[T: ProtoScalar](data: ProtoBuffer; field: int; output: var T): ProtoResult[
bool]</a></li>
<li><a class="reference" href="#getField%2CProtoBuffer%2Cint%2CT_2"
title="getField[T: seq[byte] | string](data: ProtoBuffer; field: int; output: var T): ProtoResult[
bool]">getField[T: seq[byte] | string](data: ProtoBuffer; field: int; output: var T): ProtoResult[
bool]</a></li>
</ul>
<ul class="simple nested-toc-section">getPackedRepeatedField
<li><a class="reference" href="#getPackedRepeatedField%2CProtoBuffer%2Cint%2Cseq%5BT%5D"
title="getPackedRepeatedField[T: ProtoScalar](data: ProtoBuffer; field: int;
output: var seq[T]): ProtoResult[bool]">getPackedRepeatedField[T: ProtoScalar](data: ProtoBuffer; field: int;
output: var seq[T]): ProtoResult[bool]</a></li>
</ul>
<ul class="simple nested-toc-section">getRepeatedField
<li><a class="reference" href="#getRepeatedField%2CProtoBuffer%2Cint%2Cseq%5BT%5D_2"
title="getRepeatedField[T: ProtoScalar](data: ProtoBuffer; field: int;
output: var seq[T]): ProtoResult[bool]">getRepeatedField[T: ProtoScalar](data: ProtoBuffer; field: int;
output: var seq[T]): ProtoResult[bool]</a></li>
<li><a class="reference" href="#getRepeatedField%2CProtoBuffer%2Cint%2Cseq%5BT%5D"
title="getRepeatedField[T: seq[byte] | string](data: ProtoBuffer; field: int;
output: var seq[T]): ProtoResult[bool]">getRepeatedField[T: seq[byte] | string](data: ProtoBuffer; field: int;
output: var seq[T]): ProtoResult[bool]</a></li>
</ul>
<ul class="simple nested-toc-section">getRequiredField
<li><a class="reference" href="#getRequiredField%2CProtoBuffer%2Cint%2CT"
title="getRequiredField[T](pb: ProtoBuffer; field: int; output: var T): ProtoResult[
void]">getRequiredField[T](pb: ProtoBuffer; field: int; output: var T): ProtoResult[
void]</a></li>
</ul>
<ul class="simple nested-toc-section">getRequiredRepeatedField
<li><a class="reference" href="#getRequiredRepeatedField%2CProtoBuffer%2Cint%2Cseq%5BT%5D"
title="getRequiredRepeatedField[T](pb: ProtoBuffer; field: int; output: var seq[T]): ProtoResult[
void]">getRequiredRepeatedField[T](pb: ProtoBuffer; field: int; output: var seq[T]): ProtoResult[
void]</a></li>
</ul>
<ul class="simple nested-toc-section">initProtoBuffer
<li><a class="reference" href="#initProtoBuffer%2CopenArray%5Bbyte%5D%2Cint%2Cset%5BProtoFlags%5D"
title="initProtoBuffer(data: openArray[byte]; offset = 0;
options: set[ProtoFlags] = {}; maxSize = MaxMessageSize): ProtoBuffer">initProtoBuffer(data: openArray[byte]; offset = 0;
options: set[ProtoFlags] = {}; maxSize = MaxMessageSize): ProtoBuffer</a></li>
<li><a class="reference" href="#initProtoBuffer%2Cseq%5Bbyte%5D%2Cint%2Cset%5BProtoFlags%5D"
title="initProtoBuffer(data: seq[byte]; offset = 0; options: set[ProtoFlags] = {};
maxSize = MaxMessageSize): ProtoBuffer">initProtoBuffer(data: seq[byte]; offset = 0; options: set[ProtoFlags] = {};
maxSize = MaxMessageSize): ProtoBuffer</a></li>
<li><a class="reference" href="#initProtoBuffer%2Cset%5BProtoFlags%5D"
title="initProtoBuffer(options: set[ProtoFlags] = {}; maxSize = MaxMessageSize): ProtoBuffer">initProtoBuffer(options: set[ProtoFlags] = {}; maxSize = MaxMessageSize): ProtoBuffer</a></li>
</ul>
<ul class="simple nested-toc-section">vsizeof
<li><a class="reference" href="#vsizeof%2CProtoField"
title="vsizeof(field: ProtoField): int">vsizeof(field: ProtoField): int</a></li>
</ul>
<ul class="simple nested-toc-section">write
<li><a class="reference" href="#write%2CProtoBuffer%2Cint%2CProtoBuffer"
title="write(pb: var ProtoBuffer; field: int; value: ProtoBuffer)">write(pb: var ProtoBuffer; field: int; value: ProtoBuffer)</a></li>
<li><a class="reference" href="#write%2CProtoBuffer%2Cint%2CopenArray%5BT%5D"
title="write[T: byte | char](pb: var ProtoBuffer; field: int; value: openArray[T])">write[T: byte | char](pb: var ProtoBuffer; field: int; value: openArray[T])</a></li>
<li><a class="reference" href="#write%2CProtoBuffer%2Cint%2CT"
title="write[T: ProtoScalar](pb: var ProtoBuffer; field: int; value: T)">write[T: ProtoScalar](pb: var ProtoBuffer; field: int; value: T)</a></li>
</ul>
<ul class="simple nested-toc-section">writePacked
<li><a class="reference" href="#writePacked%2CProtoBuffer%2Cint%2CopenArray%5BT%5D"
title="writePacked[T: ProtoScalar](pb: var ProtoBuffer; field: int; value: openArray[T])">writePacked[T: ProtoScalar](pb: var ProtoBuffer; field: int; value: openArray[T])</a></li>
</ul>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#18" id="68">Templates</a>
<ul class="simple simple-toc-section">
<ul class="simple nested-toc-section">checkFieldNumber
<li><a class="reference" href="#checkFieldNumber.t%2Cint"
title="checkFieldNumber(i: int)">checkFieldNumber(i: int)</a></li>
</ul>
<ul class="simple nested-toc-section">getLen
<li><a class="reference" href="#getLen.t%2CProtoBuffer"
title="getLen(pb: ProtoBuffer): int">getLen(pb: ProtoBuffer): int</a></li>
</ul>
<ul class="simple nested-toc-section">getProtoHeader
<li><a class="reference" href="#getProtoHeader.t%2CProtoField"
title="getProtoHeader(field: ProtoField): uint64">getProtoHeader(field: ProtoField): uint64</a></li>
<li><a class="reference" href="#getProtoHeader.t%2Cint%2CProtoFieldKind"
title="getProtoHeader(index: int; wire: ProtoFieldKind): uint64">getProtoHeader(index: int; wire: ProtoFieldKind): uint64</a></li>
</ul>
<ul class="simple nested-toc-section">getPtr
<li><a class="reference" href="#getPtr.t%2CProtoBuffer"
title="getPtr(pb: ProtoBuffer): pointer">getPtr(pb: ProtoBuffer): pointer</a></li>
</ul>
<ul class="simple nested-toc-section">isEmpty
<li><a class="reference" href="#isEmpty.t%2CProtoBuffer"
title="isEmpty(pb: ProtoBuffer): bool">isEmpty(pb: ProtoBuffer): bool</a></li>
</ul>
<ul class="simple nested-toc-section">isEnough
<li><a class="reference" href="#isEnough.t%2CProtoBuffer%2Cint"
title="isEnough(pb: ProtoBuffer; length: int): bool">isEnough(pb: ProtoBuffer; length: int): bool</a></li>
</ul>
<ul class="simple nested-toc-section">toOpenArray
<li><a class="reference" href="#toOpenArray.t%2CProtoBuffer"
title="toOpenArray(pb: ProtoBuffer): untyped">toOpenArray(pb: ProtoBuffer): untyped</a></li>
</ul>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#19" id="69">Exports</a>
<ul class="simple simple-toc-section">
</ul>
</li>
</ul>
</div>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L1"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
<div class="nine columns" id="content">
<div id="tocRoot"></div>
<p class="module-desc">This module implements minimal Google's ProtoBuf primitives.</p>
<div class="section" id="6">
<h1><a class="toc-backref" href="#6">Imports</a></h1>
<dl class="item">
<a class="reference external" href="../varint.html">../varint</a>, <a class="reference external" href="../utility.html">../utility</a>
</dl></div>
<div class="section" id="7">
<h1><a class="toc-backref" href="#7">Types</a></h1>
<dl class="item">
<div id="ProtoBuffer" class="tohide">
<dt><pre><a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
<span class="Identifier">options</span><span class="Other">:</span> <span class="Identifier">set</span><span class="Other">[</span><a href="minprotobuf.html#ProtoFlags"><span class="Identifier">ProtoFlags</span></a><span class="Other">]</span>
<span class="Identifier">buffer</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span>
<span class="Identifier">offset</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int</span>
<span class="Identifier">length</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int</span>
<span class="Identifier">maxSize</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">uint</span>
</pre></dt>
<dd>
Protobuf's message representation object
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L33"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L33" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="ProtoError" class="tohide">
<dt><pre><a href="minprotobuf.html#ProtoError"><span class="Identifier">ProtoError</span></a> {.<span class="Identifier">pure</span>.} <span class="Other">=</span> <span class="Keyword">enum</span>
<span class="Identifier">VarintDecode</span><span class="Other">,</span> <span class="Identifier">MessageIncomplete</span><span class="Other">,</span> <span class="Identifier">BufferOverflow</span><span class="Other">,</span> <span class="Identifier">MessageTooBig</span><span class="Other">,</span> <span class="Identifier">BadWireType</span><span class="Other">,</span>
<span class="Identifier">IncorrectBlob</span><span class="Other">,</span> <span class="Identifier">RequiredFieldMissing</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L60"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L60" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="ProtoField" class="tohide">
<dt><pre><a href="minprotobuf.html#ProtoField"><span class="Identifier">ProtoField</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
<span class="Identifier">index</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int</span>
<span class="Keyword">case</span> <span class="Identifier">kind</span><span class="Operator">*</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoFieldKind"><span class="Identifier">ProtoFieldKind</span></a>
<span class="Keyword">of</span> <span class="Identifier">Varint</span><span class="Other">:</span>
<span class="Identifier">vint</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">uint64</span>
<span class="Keyword">of</span> <span class="Identifier">Fixed64</span><span class="Other">:</span>
<span class="Identifier">vfloat64</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">float64</span>
<span class="Keyword">of</span> <span class="Identifier">Length</span><span class="Other">:</span>
<span class="Identifier">vbuffer</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span>
<span class="Keyword">of</span> <span class="Identifier">Fixed32</span><span class="Other">:</span>
<span class="Identifier">vfloat32</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">float32</span>
<span class="Keyword">of</span> <span class="Identifier">StartGroup</span><span class="Other">,</span> <span class="Identifier">EndGroup</span><span class="Other">:</span>
<span class="Keyword">nil</span>
</pre></dt>
<dd>
Protobuf's message field representation object
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L45"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L45" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="ProtoFieldKind" class="tohide">
<dt><pre><a href="minprotobuf.html#ProtoFieldKind"><span class="Identifier">ProtoFieldKind</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
<span class="Identifier">Varint</span><span class="Other">,</span> <span class="Identifier">Fixed64</span><span class="Other">,</span> <span class="Identifier">Length</span><span class="Other">,</span> <span class="Identifier">StartGroup</span><span class="Other">,</span> <span class="Identifier">EndGroup</span><span class="Other">,</span> <span class="Identifier">Fixed32</span></pre></dt>
<dd>
Protobuf's field types enum
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L25"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L25" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="ProtoFlags" class="tohide">
<dt><pre><a href="minprotobuf.html#ProtoFlags"><span class="Identifier">ProtoFlags</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
<span class="Identifier">WithVarintLength</span><span class="Other">,</span> <span class="Identifier">WithUint32BeLength</span><span class="Other">,</span> <span class="Identifier">WithUint32LeLength</span></pre></dt>
<dd>
Protobuf's encoding types
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L29"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L29" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="ProtoHeader" class="tohide">
<dt><pre><a href="minprotobuf.html#ProtoHeader"><span class="Identifier">ProtoHeader</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
<span class="Identifier">wire</span><span class="Operator">*</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoFieldKind"><span class="Identifier">ProtoFieldKind</span></a>
<span class="Identifier">index</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">uint64</span>
</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L41"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L41" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="ProtoResult" class="tohide">
<dt><pre><a href="minprotobuf.html#ProtoResult"><span class="Identifier">ProtoResult</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span> <span class="Other">=</span> <span class="Identifier">Result</span><span class="Other">[</span><span class="Identifier">T</span><span class="Other">,</span> <a href="minprotobuf.html#ProtoError"><span class="Identifier">ProtoError</span></a><span class="Other">]</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L69"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L69" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="ProtoScalar" class="tohide">
<dt><pre><a href="minprotobuf.html#ProtoScalar"><span class="Identifier">ProtoScalar</span></a> <span class="Other">=</span> <span class="Identifier">uint</span> <span class="Operator">|</span> <span class="Identifier">uint32</span> <span class="Operator">|</span> <span class="Identifier">uint64</span> <span class="Operator">|</span> <a href="../varint.html#zint"><span class="Identifier">zint</span></a> <span class="Operator">|</span> <a href="../varint.html#zint32"><span class="Identifier">zint32</span></a> <span class="Operator">|</span> <a href="../varint.html#zint64"><span class="Identifier">zint64</span></a> <span class="Operator">|</span> <a href="../varint.html#hint"><span class="Identifier">hint</span></a> <span class="Operator">|</span> <a href="../varint.html#hint32"><span class="Identifier">hint32</span></a> <span class="Operator">|</span>
<a href="../varint.html#hint64"><span class="Identifier">hint64</span></a> <span class="Operator">|</span>
<span class="Identifier">float32</span> <span class="Operator">|</span>
<span class="Identifier">float64</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L71"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L71" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
</dl></div>
<div class="section" id="10">
<h1><a class="toc-backref" href="#10">Consts</a></h1>
<dl class="item">
<div id="SupportedWireTypes" class="tohide">
<dt><pre><a href="minprotobuf.html#SupportedWireTypes"><span class="Identifier">SupportedWireTypes</span></a> <span class="Other">=</span> <span class="Other">{</span><span class="DecNumber">0</span><span class="Other">,</span> <span class="DecNumber">1</span><span class="Other">,</span> <span class="DecNumber">2</span><span class="Other">,</span> <span class="DecNumber">5</span><span class="Other">}</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L75"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L75" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
</dl></div>
<div class="section" id="12">
<h1><a class="toc-backref" href="#12">Procs</a></h1>
<dl class="item">
<div id="finish,ProtoBuffer" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#finish%2CProtoBuffer"><span class="Identifier">finish</span></a><span class="Other">(</span><span class="Identifier">pb</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> </span><span class="Identifier">public</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Prepare protobuf's buffer <tt class="docutils literal"><span class="pre">pb</span></tt> for writing to stream.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L276"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L276" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getField,ProtoBuffer,int,ProtoBuffer" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getField%2CProtoBuffer%2Cint%2CProtoBuffer"><span class="Identifier">getField</span></a><span class="Other">(</span><span class="Identifier">pb</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">;</span> <span class="Identifier">field</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">;</span> <span class="Identifier">output</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">)</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoResult"><span class="Identifier">ProtoResult</span></a><span class="Other">[</span>
<span class="Identifier">bool</span><span class="Other">]</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> </span><span class="Identifier">public</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L579"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L579" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getField,ProtoBuffer,int,openArray[T],int" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getField%2CProtoBuffer%2Cint%2CopenArray%5BT%5D%2Cint"><span class="Identifier">getField</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <span class="Identifier">byte</span> <span class="Operator">|</span> <span class="Identifier">char</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">data</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">;</span> <span class="Identifier">field</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">;</span>
<span class="Identifier">output</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">outlen</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">int</span><span class="Other">)</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoResult"><span class="Identifier">ProtoResult</span></a><span class="Other">[</span>
<span class="Identifier">bool</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> </span><span class="Identifier">public</span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L490"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L490" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getField,ProtoBuffer,int,T" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getField%2CProtoBuffer%2Cint%2CT"><span class="Identifier">getField</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoScalar"><span class="Identifier">ProtoScalar</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">data</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">;</span> <span class="Identifier">field</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">;</span> <span class="Identifier">output</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoResult"><span class="Identifier">ProtoResult</span></a><span class="Other">[</span>
<span class="Identifier">bool</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> </span><span class="Identifier">public</span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L449"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L449" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getField,ProtoBuffer,int,T_2" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getField%2CProtoBuffer%2Cint%2CT_2"><span class="Identifier">getField</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span> <span class="Operator">|</span> <span class="Identifier">string</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">data</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">;</span> <span class="Identifier">field</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">;</span>
<span class="Identifier">output</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoResult"><span class="Identifier">ProtoResult</span></a><span class="Other">[</span><span class="Identifier">bool</span><span class="Other">]</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> </span><span class="Identifier">public</span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L542"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L542" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getPackedRepeatedField,ProtoBuffer,int,seq[T]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getPackedRepeatedField%2CProtoBuffer%2Cint%2Cseq%5BT%5D"><span class="Identifier">getPackedRepeatedField</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoScalar"><span class="Identifier">ProtoScalar</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">data</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">;</span> <span class="Identifier">field</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">;</span>
<span class="Identifier">output</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoResult"><span class="Identifier">ProtoResult</span></a><span class="Other">[</span><span class="Identifier">bool</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> </span><span class="Identifier">public</span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L690"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L690" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getRepeatedField,ProtoBuffer,int,seq[T]_2" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getRepeatedField%2CProtoBuffer%2Cint%2Cseq%5BT%5D_2"><span class="Identifier">getRepeatedField</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoScalar"><span class="Identifier">ProtoScalar</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">data</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">;</span> <span class="Identifier">field</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">;</span>
<span class="Identifier">output</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoResult"><span class="Identifier">ProtoResult</span></a><span class="Other">[</span><span class="Identifier">bool</span><span class="Other">]</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> </span><span class="Identifier">public</span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L640"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L640" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getRepeatedField,ProtoBuffer,int,seq[T]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getRepeatedField%2CProtoBuffer%2Cint%2Cseq%5BT%5D"><span class="Identifier">getRepeatedField</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span> <span class="Operator">|</span> <span class="Identifier">string</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">data</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">;</span> <span class="Identifier">field</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">;</span>
<span class="Identifier">output</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoResult"><span class="Identifier">ProtoResult</span></a><span class="Other">[</span><span class="Identifier">bool</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> </span><span class="Identifier">public</span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L603"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L603" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getRequiredField,ProtoBuffer,int,T" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getRequiredField%2CProtoBuffer%2Cint%2CT"><span class="Identifier">getRequiredField</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">pb</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">;</span> <span class="Identifier">field</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">;</span> <span class="Identifier">output</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoResult"><span class="Identifier">ProtoResult</span></a><span class="Other">[</span>
<span class="Identifier">void</span><span class="Other">]</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> </span><span class="Identifier">public</span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L592"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L592" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getRequiredRepeatedField,ProtoBuffer,int,seq[T]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getRequiredRepeatedField%2CProtoBuffer%2Cint%2Cseq%5BT%5D"><span class="Identifier">getRequiredRepeatedField</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">pb</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">;</span> <span class="Identifier">field</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">;</span> <span class="Identifier">output</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoResult"><span class="Identifier">ProtoResult</span></a><span class="Other">[</span>
<span class="Identifier">void</span><span class="Other">]</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> </span><span class="Identifier">public</span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L679"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L679" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="initProtoBuffer,openArray[byte],int,set[ProtoFlags]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#initProtoBuffer%2CopenArray%5Bbyte%5D%2Cint%2Cset%5BProtoFlags%5D"><span class="Identifier">initProtoBuffer</span></a><span class="Other">(</span><span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">offset</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">;</span>
<span class="Identifier">options</span><span class="Other">:</span> <span class="Identifier">set</span><span class="Other">[</span><a href="minprotobuf.html#ProtoFlags"><span class="Identifier">ProtoFlags</span></a><span class="Other">]</span> <span class="Other">=</span> <span class="Other">{</span><span class="Other">}</span><span class="Other">;</span> <span class="Identifier">maxSize</span> <span class="Other">=</span> <span class="Identifier">MaxMessageSize</span><span class="Other">)</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> </span><span class="Identifier">public</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Initialize ProtoBuffer with copy of <tt class="docutils literal"><span class="pre">data</span></tt>.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L133"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L133" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="initProtoBuffer,seq[byte],int,set[ProtoFlags]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#initProtoBuffer%2Cseq%5Bbyte%5D%2Cint%2Cset%5BProtoFlags%5D"><span class="Identifier">initProtoBuffer</span></a><span class="Other">(</span><span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">offset</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">;</span> <span class="Identifier">options</span><span class="Other">:</span> <span class="Identifier">set</span><span class="Other">[</span><a href="minprotobuf.html#ProtoFlags"><span class="Identifier">ProtoFlags</span></a><span class="Other">]</span> <span class="Other">=</span> <span class="Other">{</span><span class="Other">}</span><span class="Other">;</span>
<span class="Identifier">maxSize</span> <span class="Other">=</span> <span class="Identifier">MaxMessageSize</span><span class="Other">)</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
</span><span class="Identifier">public</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Initialize ProtoBuffer with shallow copy of <tt class="docutils literal"><span class="pre">data</span></tt>.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L124"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L124" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="initProtoBuffer,set[ProtoFlags]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#initProtoBuffer%2Cset%5BProtoFlags%5D"><span class="Identifier">initProtoBuffer</span></a><span class="Other">(</span><span class="Identifier">options</span><span class="Other">:</span> <span class="Identifier">set</span><span class="Other">[</span><a href="minprotobuf.html#ProtoFlags"><span class="Identifier">ProtoFlags</span></a><span class="Other">]</span> <span class="Other">=</span> <span class="Other">{</span><span class="Other">}</span><span class="Other">;</span> <span class="Identifier">maxSize</span> <span class="Other">=</span> <span class="Identifier">MaxMessageSize</span><span class="Other">)</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> </span><span class="Identifier">public</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Initialize ProtoBuffer with new sequence of capacity <tt class="docutils literal"><span class="pre">cap</span></tt>.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L142"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L142" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="vsizeof,ProtoField" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#vsizeof%2CProtoField"><span class="Identifier">vsizeof</span></a><span class="Other">(</span><span class="Identifier">field</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoField"><span class="Identifier">ProtoField</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">int</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> </span><span class="Identifier">public</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Returns number of bytes required to store protobuf's field <tt class="docutils literal"><span class="pre">field</span></tt>.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L109"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L109" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="write,ProtoBuffer,int,ProtoBuffer" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#write%2CProtoBuffer%2Cint%2CProtoBuffer"><span class="Identifier">write</span></a><span class="Other">(</span><span class="Identifier">pb</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">;</span> <span class="Identifier">field</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">)</span> {.<span class="Identifier">inline</span><span class="Other">,</span>
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> </span><span class="Identifier">public</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Encode Protobuf's sub-message <tt class="docutils literal"><span class="pre">value</span></tt> and store it to protobuf's buffer <tt class="docutils literal"><span class="pre">pb</span></tt> with field number <tt class="docutils literal"><span class="pre">field</span></tt>.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L271"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L271" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="write,ProtoBuffer,int,openArray[T]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#write%2CProtoBuffer%2Cint%2CopenArray%5BT%5D"><span class="Identifier">write</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <span class="Identifier">byte</span> <span class="Operator">|</span> <span class="Identifier">char</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">pb</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">;</span> <span class="Identifier">field</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> </span><span class="Identifier">public</span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L251"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L251" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="write,ProtoBuffer,int,T" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#write%2CProtoBuffer%2Cint%2CT"><span class="Identifier">write</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoScalar"><span class="Identifier">ProtoScalar</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">pb</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">;</span> <span class="Identifier">field</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> </span><span class="Identifier">public</span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L158"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L158" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="writePacked,ProtoBuffer,int,openArray[T]" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#writePacked%2CProtoBuffer%2Cint%2CopenArray%5BT%5D"><span class="Identifier">writePacked</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoScalar"><span class="Identifier">ProtoScalar</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">pb</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">;</span> <span class="Identifier">field</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">;</span>
<span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> </span><span class="Identifier">public</span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L203"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L203" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
</dl></div>
<div class="section" id="18">
<h1><a class="toc-backref" href="#18">Templates</a></h1>
<dl class="item">
<div id="checkFieldNumber.t,int" class="tohide">
<dt><pre><span class="Keyword">template</span> <a href="#checkFieldNumber.t%2Cint"><span class="Identifier">checkFieldNumber</span></a><span class="Other">(</span><span class="Identifier">i</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L82"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L82" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getLen.t,ProtoBuffer" class="tohide">
<dt><pre><span class="Keyword">template</span> <a href="#getLen.t%2CProtoBuffer"><span class="Identifier">getLen</span></a><span class="Other">(</span><span class="Identifier">pb</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">int</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L106"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L106" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getProtoHeader.t,ProtoField" class="tohide">
<dt><pre><span class="Keyword">template</span> <a href="#getProtoHeader.t%2CProtoField"><span class="Identifier">getProtoHeader</span></a><span class="Other">(</span><span class="Identifier">field</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoField"><span class="Identifier">ProtoField</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">uint64</span></pre></dt>
<dd>
Get protobuf's field header integer for <tt class="docutils literal"><span class="pre">field</span></tt>.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L90"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L90" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getProtoHeader.t,int,ProtoFieldKind" class="tohide">
<dt><pre><span class="Keyword">template</span> <a href="#getProtoHeader.t%2Cint%2CProtoFieldKind"><span class="Identifier">getProtoHeader</span></a><span class="Other">(</span><span class="Identifier">index</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">;</span> <span class="Identifier">wire</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoFieldKind"><span class="Identifier">ProtoFieldKind</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">uint64</span></pre></dt>
<dd>
Get protobuf's field header integer for <tt class="docutils literal"><span class="pre">index</span></tt> and <tt class="docutils literal"><span class="pre">wire</span></tt>.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L86"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L86" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getPtr.t,ProtoBuffer" class="tohide">
<dt><pre><span class="Keyword">template</span> <a href="#getPtr.t%2CProtoBuffer"><span class="Identifier">getPtr</span></a><span class="Other">(</span><span class="Identifier">pb</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">pointer</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L103"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L103" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="isEmpty.t,ProtoBuffer" class="tohide">
<dt><pre><span class="Keyword">template</span> <a href="#isEmpty.t%2CProtoBuffer"><span class="Identifier">isEmpty</span></a><span class="Other">(</span><span class="Identifier">pb</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L97"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L97" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="isEnough.t,ProtoBuffer,int" class="tohide">
<dt><pre><span class="Keyword">template</span> <a href="#isEnough.t%2CProtoBuffer%2Cint"><span class="Identifier">isEnough</span></a><span class="Other">(</span><span class="Identifier">pb</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">;</span> <span class="Identifier">length</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L100"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L100" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="toOpenArray.t,ProtoBuffer" class="tohide">
<dt><pre><span class="Keyword">template</span> <a href="#toOpenArray.t%2CProtoBuffer"><span class="Identifier">toOpenArray</span></a><span class="Other">(</span><span class="Identifier">pb</span><span class="Other">:</span> <a href="minprotobuf.html#ProtoBuffer"><span class="Identifier">ProtoBuffer</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">untyped</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/protobuf/minprotobuf.nim#L94"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/protobuf/minprotobuf.nim#L94" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
</dl></div>
<div class="section" id="19">
<h1><a class="toc-backref" href="#19">Exports</a></h1>
<dl class="item">
<a href="../utility.html#compilesOr.t,untyped,untyped"><span class="Identifier">compilesOr</span></a>, <a href="../utility.html#shortLog,string"><span class="Identifier">shortLog</span></a>, <a href="../utility.html#shortLog,openArray[byte]"><span class="Identifier">shortLog</span></a>, <a href="../utility.html#public.t"><span class="Identifier">public</span></a>
</dl></div>
</div>
</div>
<div class="row">
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2023-04-13 10:58:57 UTC</small>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,314 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- This file is generated by Nim. -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Favicon -->
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
<!-- Google fonts -->
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
<!-- CSS -->
<title>libp2p/utility</title>
<link rel="stylesheet" type="text/css" href="../nimdoc.out.css">
<script type="text/javascript" src="../dochack.js"></script>
<script type="text/javascript">
function main() {
var pragmaDots = document.getElementsByClassName("pragmadots");
for (var i = 0; i < pragmaDots.length; i++) {
pragmaDots[i].onclick = function(event) {
// Hide tease
event.target.parentNode.style.display = "none";
// Show actual
event.target.parentNode.nextElementSibling.style.display = "inline";
}
}
function switchTheme(e) {
if (e.target.checked) {
document.documentElement.setAttribute('data-theme', 'dark');
localStorage.setItem('theme', 'dark');
} else {
document.documentElement.setAttribute('data-theme', 'light');
localStorage.setItem('theme', 'light');
}
}
const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');
if (toggleSwitch !== null) {
toggleSwitch.addEventListener('change', switchTheme, false);
}
var currentTheme = localStorage.getItem('theme');
if (!currentTheme && window.matchMedia('(prefers-color-scheme: dark)').matches) {
currentTheme = 'dark';
}
if (currentTheme) {
document.documentElement.setAttribute('data-theme', currentTheme);
if (currentTheme === 'dark' && toggleSwitch !== null) {
toggleSwitch.checked = true;
}
}
}
window.addEventListener('DOMContentLoaded', main);
</script>
</head>
<body>
<div class="document" id="documentId">
<div class="container">
<h1 class="title">libp2p/utility</h1>
<div class="row">
<div class="three columns">
<div class="theme-switch-wrapper">
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox" />
<div class="slider round"></div>
</label>
&nbsp;&nbsp;&nbsp; <em>Dark Mode</em>
</div>
<div id="global-links">
<ul class="simple">
<li>
<a href="../theindex.html">Index</a>
</li>
</ul>
</div>
<div id="searchInputDiv">
Search: <input type="text" id="searchInput"
onkeyup="search()" />
</div>
<div>
Group by:
<select onchange="groupBy(this.value)">
<option value="section">Section</option>
<option value="type">Type</option>
</select>
</div>
<script type="text/javascript">
function main2() {
// Create the slider
var firstSlider = document.getElementsByClassName("theme-switch-wrapper")[0];
var newSlider = document.createRange().createContextualFragment(`
<div class="theme-switch-wrapper">
<label class="theme-switch" for="internalcheckbox">
<input type="checkbox" id="internalcheckbox">
<div class="slider round"></div>
</label>
&nbsp;&nbsp;&nbsp; <em>Internal</em>
</div>
`);
var sliderInst = firstSlider.after(newSlider);
// Restore slider state from storage
var currentMode = localStorage.getItem('privateMode');
if (currentMode == "private") {
document.getElementById("internalcheckbox").checked = true;
} else {
hidePrivateProcs();
}
document.getElementById("internalcheckbox").onclick = togglePrivateProcs;
}
function hidePrivateProcs() {
var toHide = document.getElementsByClassName("tohide");
for (var i = 0; i < toHide.length; i++) {
var pragmas = toHide[i].querySelectorAll("span.Identifier");
var public = false;
for (var z = 0; z < pragmas.length; z++) {
if (pragmas[z].innerText == "public") {
public = true;
break;
}
}
if (public == false) {
toHide[i].style.display = "none";
toHide[i].classList.add("hidden");
links = document.querySelectorAll("a[href='#" + encodeURIComponent(toHide[i].id) + "']");
for (var y = 0; y < links.length; y++) {
links[y].parentNode.style.display = "none";
links[y].parentNode.classList.add("hidden");
}
}
}
// TOC
var nestedSections = document.getElementsByClassName("nested-toc-section");
for (var i = 0; i < nestedSections.length; i++) {
if (nestedSections[i].querySelectorAll("li:not(.hidden)").length == 0) {
nestedSections[i].style.display = "none";
nestedSections[i].classList.add("hidden");
}
}
var sections = document.getElementsByClassName("simple-toc-section");
for (var i = 0; i < sections.length; i++) {
if (sections[i].querySelectorAll(".nested-toc-section:not(.hidden)").length == 0) {
sections[i].parentNode.style.display = "none";
sections[i].parentNode.classList.add("hidden");
}
}
// Sections
var sections = document.getElementsByClassName("section");
for (var i = 0; i < sections.length; i++) {
if (sections[i].querySelectorAll(".item > div").length == 0) continue;
if (sections[i].querySelectorAll(".item > div:not(.hidden)").length == 0) {
sections[i].style.display = "none";
sections[i].classList.add("hidden");
}
}
}
function showPrivateProcs() {
var toHide = Array.from(document.getElementsByClassName("hidden"));
for (var i = 0; i < toHide.length; i++) {
toHide[i].style.display = "";
toHide[i].classList.remove("hidden");
}
}
function togglePrivateProcs() {
if (document.getElementById("internalcheckbox").checked) {
localStorage.setItem('privateMode', 'private');
showPrivateProcs();
} else {
localStorage.setItem('privateMode', 'public');
hidePrivateProcs();
}
}
window.addEventListener("DOMContentLoaded", main2);
</script>
<ul class="simple simple-toc" id="toc-list">
<li>
<a class="reference reference-toplevel" href="#12" id="62">Procs</a>
<ul class="simple simple-toc-section">
<ul class="simple nested-toc-section">shortLog
<li><a class="reference" href="#shortLog%2CopenArray%5Bbyte%5D"
title="shortLog(item: openArray[byte]): string">shortLog(item: openArray[byte]): string</a></li>
<li><a class="reference" href="#shortLog%2Cstring"
title="shortLog(item: string): string">shortLog(item: string): string</a></li>
</ul>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#18" id="68">Templates</a>
<ul class="simple simple-toc-section">
<ul class="simple nested-toc-section">compilesOr
<li><a class="reference" href="#compilesOr.t%2Cuntyped%2Cuntyped"
title="compilesOr(a, b: untyped): untyped">compilesOr(a, b: untyped): untyped</a></li>
</ul>
<ul class="simple nested-toc-section">public
<li><a class="reference" href="#public.t"
title="public()">public()</a></li>
</ul>
</ul>
</li>
</ul>
</div>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/utility.nim#L1"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/utility.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
<div class="nine columns" id="content">
<div id="tocRoot"></div>
<p class="module-desc"></p>
<div class="section" id="12">
<h1><a class="toc-backref" href="#12">Procs</a></h1>
<dl class="item">
<div id="shortLog,openArray[byte]" class="tohide">
<dt><pre><span class="Keyword">func</span> <a href="#shortLog%2CopenArray%5Bbyte%5D"><span class="Identifier">shortLog</span></a><span class="Other">(</span><span class="Identifier">item</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/utility.nim#L28"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/utility.nim#L28" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="shortLog,string" class="tohide">
<dt><pre><span class="Keyword">func</span> <a href="#shortLog%2Cstring"><span class="Identifier">shortLog</span></a><span class="Other">(</span><span class="Identifier">item</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/utility.nim#L40"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/utility.nim#L40" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
</dl></div>
<div class="section" id="18">
<h1><a class="toc-backref" href="#18">Templates</a></h1>
<dl class="item">
<div id="compilesOr.t,untyped,untyped" class="tohide">
<dt><pre><span class="Keyword">template</span> <a href="#compilesOr.t%2Cuntyped%2Cuntyped"><span class="Identifier">compilesOr</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <span class="Identifier">untyped</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">untyped</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/utility.nim#L22"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/utility.nim#L22" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="public.t" class="tohide">
<dt><pre><span class="Keyword">template</span> <a href="#public.t"><span class="Identifier">public</span></a><span class="Other">(</span><span class="Other">)</span> {.<span class="Identifier">pragma</span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/utility.nim#L17"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/utility.nim#L17" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
</dl></div>
</div>
</div>
<div class="row">
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2023-04-13 10:58:57 UTC</small>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,735 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- This file is generated by Nim. -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Favicon -->
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
<!-- Google fonts -->
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
<!-- CSS -->
<title>libp2p/varint</title>
<link rel="stylesheet" type="text/css" href="../nimdoc.out.css">
<script type="text/javascript" src="../dochack.js"></script>
<script type="text/javascript">
function main() {
var pragmaDots = document.getElementsByClassName("pragmadots");
for (var i = 0; i < pragmaDots.length; i++) {
pragmaDots[i].onclick = function(event) {
// Hide tease
event.target.parentNode.style.display = "none";
// Show actual
event.target.parentNode.nextElementSibling.style.display = "inline";
}
}
function switchTheme(e) {
if (e.target.checked) {
document.documentElement.setAttribute('data-theme', 'dark');
localStorage.setItem('theme', 'dark');
} else {
document.documentElement.setAttribute('data-theme', 'light');
localStorage.setItem('theme', 'light');
}
}
const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');
if (toggleSwitch !== null) {
toggleSwitch.addEventListener('change', switchTheme, false);
}
var currentTheme = localStorage.getItem('theme');
if (!currentTheme && window.matchMedia('(prefers-color-scheme: dark)').matches) {
currentTheme = 'dark';
}
if (currentTheme) {
document.documentElement.setAttribute('data-theme', currentTheme);
if (currentTheme === 'dark' && toggleSwitch !== null) {
toggleSwitch.checked = true;
}
}
}
window.addEventListener('DOMContentLoaded', main);
</script>
</head>
<body>
<div class="document" id="documentId">
<div class="container">
<h1 class="title">libp2p/varint</h1>
<div class="row">
<div class="three columns">
<div class="theme-switch-wrapper">
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox" />
<div class="slider round"></div>
</label>
&nbsp;&nbsp;&nbsp; <em>Dark Mode</em>
</div>
<div id="global-links">
<ul class="simple">
<li>
<a href="../theindex.html">Index</a>
</li>
</ul>
</div>
<div id="searchInputDiv">
Search: <input type="text" id="searchInput"
onkeyup="search()" />
</div>
<div>
Group by:
<select onchange="groupBy(this.value)">
<option value="section">Section</option>
<option value="type">Type</option>
</select>
</div>
<script type="text/javascript">
function main2() {
// Create the slider
var firstSlider = document.getElementsByClassName("theme-switch-wrapper")[0];
var newSlider = document.createRange().createContextualFragment(`
<div class="theme-switch-wrapper">
<label class="theme-switch" for="internalcheckbox">
<input type="checkbox" id="internalcheckbox">
<div class="slider round"></div>
</label>
&nbsp;&nbsp;&nbsp; <em>Internal</em>
</div>
`);
var sliderInst = firstSlider.after(newSlider);
// Restore slider state from storage
var currentMode = localStorage.getItem('privateMode');
if (currentMode == "private") {
document.getElementById("internalcheckbox").checked = true;
} else {
hidePrivateProcs();
}
document.getElementById("internalcheckbox").onclick = togglePrivateProcs;
}
function hidePrivateProcs() {
var toHide = document.getElementsByClassName("tohide");
for (var i = 0; i < toHide.length; i++) {
var pragmas = toHide[i].querySelectorAll("span.Identifier");
var public = false;
for (var z = 0; z < pragmas.length; z++) {
if (pragmas[z].innerText == "public") {
public = true;
break;
}
}
if (public == false) {
toHide[i].style.display = "none";
toHide[i].classList.add("hidden");
links = document.querySelectorAll("a[href='#" + encodeURIComponent(toHide[i].id) + "']");
for (var y = 0; y < links.length; y++) {
links[y].parentNode.style.display = "none";
links[y].parentNode.classList.add("hidden");
}
}
}
// TOC
var nestedSections = document.getElementsByClassName("nested-toc-section");
for (var i = 0; i < nestedSections.length; i++) {
if (nestedSections[i].querySelectorAll("li:not(.hidden)").length == 0) {
nestedSections[i].style.display = "none";
nestedSections[i].classList.add("hidden");
}
}
var sections = document.getElementsByClassName("simple-toc-section");
for (var i = 0; i < sections.length; i++) {
if (sections[i].querySelectorAll(".nested-toc-section:not(.hidden)").length == 0) {
sections[i].parentNode.style.display = "none";
sections[i].parentNode.classList.add("hidden");
}
}
// Sections
var sections = document.getElementsByClassName("section");
for (var i = 0; i < sections.length; i++) {
if (sections[i].querySelectorAll(".item > div").length == 0) continue;
if (sections[i].querySelectorAll(".item > div:not(.hidden)").length == 0) {
sections[i].style.display = "none";
sections[i].classList.add("hidden");
}
}
}
function showPrivateProcs() {
var toHide = Array.from(document.getElementsByClassName("hidden"));
for (var i = 0; i < toHide.length; i++) {
toHide[i].style.display = "";
toHide[i].classList.remove("hidden");
}
}
function togglePrivateProcs() {
if (document.getElementById("internalcheckbox").checked) {
localStorage.setItem('privateMode', 'private');
showPrivateProcs();
} else {
localStorage.setItem('privateMode', 'public');
hidePrivateProcs();
}
}
window.addEventListener("DOMContentLoaded", main2);
</script>
<ul class="simple simple-toc" id="toc-list">
<li>
<a class="reference reference-toplevel" href="#7" id="57">Types</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#hint"
title="hint = distinct int">hint</a></li>
<li><a class="reference" href="#hint32"
title="hint32 = distinct int32">hint32</a></li>
<li><a class="reference" href="#hint64"
title="hint64 = distinct int64">hint64</a></li>
<li><a class="reference" href="#LP"
title="LP = object">LP</a></li>
<li><a class="reference" href="#LPSomeUVarint"
title="LPSomeUVarint = uint | uint64 | uint32 | uint16 | uint8">LPSomeUVarint</a></li>
<li><a class="reference" href="#LPSomeVarint"
title="LPSomeVarint = LPSomeUVarint">LPSomeVarint</a></li>
<li><a class="reference" href="#PB"
title="PB = object">PB</a></li>
<li><a class="reference" href="#PBSomeSVarint"
title="PBSomeSVarint = hint | hint64 | hint32">PBSomeSVarint</a></li>
<li><a class="reference" href="#PBSomeUVarint"
title="PBSomeUVarint = uint | uint64 | uint32">PBSomeUVarint</a></li>
<li><a class="reference" href="#PBSomeVarint"
title="PBSomeVarint = PBSomeUVarint | PBSomeSVarint | PBZigVarint">PBSomeVarint</a></li>
<li><a class="reference" href="#PBZigVarint"
title="PBZigVarint = zint | zint64 | zint32">PBZigVarint</a></li>
<li><a class="reference" href="#SomeUVarint"
title="SomeUVarint = PBSomeUVarint | LPSomeUVarint">SomeUVarint</a></li>
<li><a class="reference" href="#SomeVarint"
title="SomeVarint = PBSomeVarint | LPSomeVarint">SomeVarint</a></li>
<li><a class="reference" href="#VarintError"
title="VarintError {.pure.} = enum
Error, Overflow, Incomplete, Overlong, Overrun">VarintError</a></li>
<li><a class="reference" href="#VarintResult"
title="VarintResult[T] = Result[T, VarintError]">VarintResult</a></li>
<li><a class="reference" href="#zint"
title="zint = distinct int">zint</a></li>
<li><a class="reference" href="#zint32"
title="zint32 = distinct int32">zint32</a></li>
<li><a class="reference" href="#zint64"
title="zint64 = distinct int64">zint64</a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#12" id="62">Procs</a>
<ul class="simple simple-toc-section">
<ul class="simple nested-toc-section">encodeVarint
<li><a class="reference" href="#encodeVarint%2Ctypedesc%5BLP%5D%2CLPSomeVarint"
title="encodeVarint(vtype: typedesc[LP]; value: LPSomeVarint): VarintResult[seq[byte]]">encodeVarint(vtype: typedesc[LP]; value: LPSomeVarint): VarintResult[seq[byte]]</a></li>
<li><a class="reference" href="#encodeVarint%2Ctypedesc%5BPB%5D%2CPBSomeVarint"
title="encodeVarint(vtype: typedesc[PB]; value: PBSomeVarint): VarintResult[seq[byte]]">encodeVarint(vtype: typedesc[PB]; value: PBSomeVarint): VarintResult[seq[byte]]</a></li>
</ul>
<ul class="simple nested-toc-section">getSVarint
<li><a class="reference" href="#getSVarint%2CopenArray%5Bbyte%5D%2Cint%2C"
title="getSVarint(pbytes: openArray[byte]; outsize: var int;
outval: var (PBZigVarint | PBSomeSVarint)): VarintResult[void]">getSVarint(pbytes: openArray[byte]; outsize: var int;
outval: var (PBZigVarint | PBSomeSVarint)): VarintResult[void]</a></li>
</ul>
<ul class="simple nested-toc-section">getUVarint
<li><a class="reference" href="#getUVarint%2Ctypedesc%5BT%5D%2CopenArray%5Bbyte%5D%2Cint%2CSomeUVarint"
title="getUVarint[T: PB | LP](vtype: typedesc[T]; pbytes: openArray[byte];
outlen: var int; outval: var SomeUVarint): VarintResult[
void]">getUVarint[T: PB | LP](vtype: typedesc[T]; pbytes: openArray[byte];
outlen: var int; outval: var SomeUVarint): VarintResult[
void]</a></li>
</ul>
<ul class="simple nested-toc-section">getVarint
<li><a class="reference" href="#getVarint%2Ctypedesc%5BT%5D%2CopenArray%5Bbyte%5D%2Cint%2CSomeVarint"
title="getVarint[T: PB | LP](vtype: typedesc[T]; pbytes: openArray[byte];
nbytes: var int; value: var SomeVarint): VarintResult[void]">getVarint[T: PB | LP](vtype: typedesc[T]; pbytes: openArray[byte];
nbytes: var int; value: var SomeVarint): VarintResult[void]</a></li>
</ul>
<ul class="simple nested-toc-section">putSVarint
<li><a class="reference" href="#putSVarint%2CopenArray%5Bbyte%5D%2Cint%2C"
title="putSVarint(pbytes: var openArray[byte]; outsize: var int;
outval: (PBZigVarint | PBSomeSVarint)): VarintResult[void]">putSVarint(pbytes: var openArray[byte]; outsize: var int;
outval: (PBZigVarint | PBSomeSVarint)): VarintResult[void]</a></li>
</ul>
<ul class="simple nested-toc-section">putUVarint
<li><a class="reference" href="#putUVarint%2Ctypedesc%5BT%5D%2CopenArray%5Bbyte%5D%2Cint%2CSomeUVarint"
title="putUVarint[T: PB | LP](vtype: typedesc[T]; pbytes: var openArray[byte];
outlen: var int; outval: SomeUVarint): VarintResult[void]">putUVarint[T: PB | LP](vtype: typedesc[T]; pbytes: var openArray[byte];
outlen: var int; outval: SomeUVarint): VarintResult[void]</a></li>
</ul>
<ul class="simple nested-toc-section">putVarint
<li><a class="reference" href="#putVarint%2Ctypedesc%5BT%5D%2CopenArray%5Bbyte%5D%2Cint%2CSomeVarint"
title="putVarint[T: PB | LP](vtype: typedesc[T]; pbytes: var openArray[byte];
nbytes: var int; value: SomeVarint): VarintResult[void]">putVarint[T: PB | LP](vtype: typedesc[T]; pbytes: var openArray[byte];
nbytes: var int; value: SomeVarint): VarintResult[void]</a></li>
</ul>
<ul class="simple nested-toc-section">vsizeof
<li><a class="reference" href="#vsizeof%2CSomeVarint"
title="vsizeof(x: SomeVarint): int">vsizeof(x: SomeVarint): int</a></li>
</ul>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#18" id="68">Templates</a>
<ul class="simple simple-toc-section">
<ul class="simple nested-toc-section">toBytes
<li><a class="reference" href="#toBytes.t%2Ctypedesc%5BPB%5D%2CPBSomeVarint"
title="toBytes(vtype: typedesc[PB]; value: PBSomeVarint): auto">toBytes(vtype: typedesc[PB]; value: PBSomeVarint): auto</a></li>
</ul>
</ul>
</li>
</ul>
</div>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L1"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
<div class="nine columns" id="content">
<div id="tocRoot"></div>
<p class="module-desc">This module implements Variable Integer <tt class="docutils literal"><span class="pre"><span class="Identifier">VARINT</span></span></tt>. This module supports two variants of variable integer<ul class="simple"><li>Google ProtoBuf varint, which is able to encode full uint64 number and maximum size of encoded value is 10 octets (bytes). <a class="reference external" href="https://developers.google.com/protocol-buffers/docs/encoding#varints">https://developers.google.com/protocol-buffers/docs/encoding#varints</a></li>
<li>LibP2P varint, which is able to encode only 63bits of uint64 number and maximum size of encoded value is 9 octets (bytes). <a class="reference external" href="https://github.com/multiformats/unsigned-varint">https://github.com/multiformats/unsigned-varint</a></li>
</ul>
</p>
<div class="section" id="7">
<h1><a class="toc-backref" href="#7">Types</a></h1>
<dl class="item">
<div id="hint" class="tohide">
<dt><pre><a href="varint.html#hint"><span class="Identifier">hint</span></a> <span class="Other">=</span> <span class="Keyword">distinct</span> <span class="Identifier">int</span></pre></dt>
<dd>
Signed integer types which will be encoded using simple cast.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L49"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L49" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="hint32" class="tohide">
<dt><pre><a href="varint.html#hint32"><span class="Identifier">hint32</span></a> <span class="Other">=</span> <span class="Keyword">distinct</span> <span class="Identifier">int32</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L47"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L47" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="hint64" class="tohide">
<dt><pre><a href="varint.html#hint64"><span class="Identifier">hint64</span></a> <span class="Other">=</span> <span class="Keyword">distinct</span> <span class="Identifier">int64</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L48"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L48" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="LP" class="tohide">
<dt><pre><a href="varint.html#LP"><span class="Identifier">LP</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
</pre></dt>
<dd>
Use this type to specify LibP2P varint encoding
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L39"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L39" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="LPSomeUVarint" class="tohide">
<dt><pre><a href="varint.html#LPSomeUVarint"><span class="Identifier">LPSomeUVarint</span></a> <span class="Other">=</span> <span class="Identifier">uint</span> <span class="Operator">|</span> <span class="Identifier">uint64</span> <span class="Operator">|</span> <span class="Identifier">uint32</span> <span class="Operator">|</span> <span class="Identifier">uint16</span> <span class="Operator">|</span> <span class="Identifier">uint8</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L56"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L56" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="LPSomeVarint" class="tohide">
<dt><pre><a href="varint.html#LPSomeVarint"><span class="Identifier">LPSomeVarint</span></a> <span class="Other">=</span> <a href="varint.html#LPSomeUVarint"><span class="Identifier">LPSomeUVarint</span></a></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L57"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L57" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="PB" class="tohide">
<dt><pre><a href="varint.html#PB"><span class="Identifier">PB</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
</pre></dt>
<dd>
Use this type to specify Google ProtoBuf's varint encoding
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L37"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L37" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="PBSomeSVarint" class="tohide">
<dt><pre><a href="varint.html#PBSomeSVarint"><span class="Identifier">PBSomeSVarint</span></a> <span class="Other">=</span> <a href="varint.html#hint"><span class="Identifier">hint</span></a> <span class="Operator">|</span> <a href="varint.html#hint64"><span class="Identifier">hint64</span></a> <span class="Operator">|</span> <a href="varint.html#hint32"><span class="Identifier">hint32</span></a></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L53"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L53" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="PBSomeUVarint" class="tohide">
<dt><pre><a href="varint.html#PBSomeUVarint"><span class="Identifier">PBSomeUVarint</span></a> <span class="Other">=</span> <span class="Identifier">uint</span> <span class="Operator">|</span> <span class="Identifier">uint64</span> <span class="Operator">|</span> <span class="Identifier">uint32</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L52"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L52" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="PBSomeVarint" class="tohide">
<dt><pre><a href="varint.html#PBSomeVarint"><span class="Identifier">PBSomeVarint</span></a> <span class="Other">=</span> <a href="varint.html#PBSomeUVarint"><span class="Identifier">PBSomeUVarint</span></a> <span class="Operator">|</span> <a href="varint.html#PBSomeSVarint"><span class="Identifier">PBSomeSVarint</span></a> <span class="Operator">|</span> <a href="varint.html#PBZigVarint"><span class="Identifier">PBZigVarint</span></a></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L55"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L55" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="PBZigVarint" class="tohide">
<dt><pre><a href="varint.html#PBZigVarint"><span class="Identifier">PBZigVarint</span></a> <span class="Other">=</span> <a href="varint.html#zint"><span class="Identifier">zint</span></a> <span class="Operator">|</span> <a href="varint.html#zint64"><span class="Identifier">zint64</span></a> <span class="Operator">|</span> <a href="varint.html#zint32"><span class="Identifier">zint32</span></a></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L54"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L54" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="SomeUVarint" class="tohide">
<dt><pre><a href="varint.html#SomeUVarint"><span class="Identifier">SomeUVarint</span></a> <span class="Other">=</span> <a href="varint.html#PBSomeUVarint"><span class="Identifier">PBSomeUVarint</span></a> <span class="Operator">|</span> <a href="varint.html#LPSomeUVarint"><span class="Identifier">LPSomeUVarint</span></a></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L59"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L59" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="SomeVarint" class="tohide">
<dt><pre><a href="varint.html#SomeVarint"><span class="Identifier">SomeVarint</span></a> <span class="Other">=</span> <a href="varint.html#PBSomeVarint"><span class="Identifier">PBSomeVarint</span></a> <span class="Operator">|</span> <a href="varint.html#LPSomeVarint"><span class="Identifier">LPSomeVarint</span></a></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L58"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L58" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="VarintError" class="tohide">
<dt><pre><a href="varint.html#VarintError"><span class="Identifier">VarintError</span></a> {.<span class="Identifier">pure</span>.} <span class="Other">=</span> <span class="Keyword">enum</span>
<span class="Identifier">Error</span><span class="Other">,</span> <span class="Identifier">Overflow</span><span class="Other">,</span> <span class="Identifier">Incomplete</span><span class="Other">,</span> <span class="Identifier">Overlong</span><span class="Other">,</span> <span class="Identifier">Overrun</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L28"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L28" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="VarintResult" class="tohide">
<dt><pre><a href="varint.html#VarintResult"><span class="Identifier">VarintResult</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span> <span class="Other">=</span> <span class="Identifier">Result</span><span class="Other">[</span><span class="Identifier">T</span><span class="Other">,</span> <a href="varint.html#VarintError"><span class="Identifier">VarintError</span></a><span class="Other">]</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L35"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L35" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="zint" class="tohide">
<dt><pre><a href="varint.html#zint"><span class="Identifier">zint</span></a> <span class="Other">=</span> <span class="Keyword">distinct</span> <span class="Identifier">int</span></pre></dt>
<dd>
Signed integer types which will be encoded using zigzag encoding.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L44"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L44" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="zint32" class="tohide">
<dt><pre><a href="varint.html#zint32"><span class="Identifier">zint32</span></a> <span class="Other">=</span> <span class="Keyword">distinct</span> <span class="Identifier">int32</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L42"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L42" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="zint64" class="tohide">
<dt><pre><a href="varint.html#zint64"><span class="Identifier">zint64</span></a> <span class="Other">=</span> <span class="Keyword">distinct</span> <span class="Identifier">int64</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L43"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L43" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
</dl></div>
<div class="section" id="12">
<h1><a class="toc-backref" href="#12">Procs</a></h1>
<dl class="item">
<div id="encodeVarint,typedesc[LP],LPSomeVarint" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#encodeVarint%2Ctypedesc%5BLP%5D%2CLPSomeVarint"><span class="Identifier">encodeVarint</span></a><span class="Other">(</span><span class="Identifier">vtype</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="varint.html#LP"><span class="Identifier">LP</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <a href="varint.html#LPSomeVarint"><span class="Identifier">LPSomeVarint</span></a><span class="Other">)</span><span class="Other">:</span> <a href="varint.html#VarintResult"><span class="Identifier">VarintResult</span></a><span class="Other">[</span>
<span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">]</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Encode integer to LibP2P <tt class="docutils literal"><span class="pre"><span class="Identifier">unsigned</span> <span class="Identifier">varint</span></span></tt> and returns sequence of bytes as buffer.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L291"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L291" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="encodeVarint,typedesc[PB],PBSomeVarint" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#encodeVarint%2Ctypedesc%5BPB%5D%2CPBSomeVarint"><span class="Identifier">encodeVarint</span></a><span class="Other">(</span><span class="Identifier">vtype</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="varint.html#PB"><span class="Identifier">PB</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <a href="varint.html#PBSomeVarint"><span class="Identifier">PBSomeVarint</span></a><span class="Other">)</span><span class="Other">:</span> <a href="varint.html#VarintResult"><span class="Identifier">VarintResult</span></a><span class="Other">[</span>
<span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">]</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Encode integer to Google ProtoBuf's <tt class="docutils literal"><span class="pre"><span class="Identifier">signed</span><span class="Operator">/</span><span class="Identifier">unsigned</span> <span class="Identifier">varint</span></span></tt> and returns sequence of bytes as buffer.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L271"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L271" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getSVarint,openArray[byte],int," class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getSVarint%2CopenArray%5Bbyte%5D%2Cint%2C"><span class="Identifier">getSVarint</span></a><span class="Other">(</span><span class="Identifier">pbytes</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">outsize</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">int</span><span class="Other">;</span>
<span class="Identifier">outval</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Other">(</span><a href="varint.html#PBZigVarint"><span class="Identifier">PBZigVarint</span></a> <span class="Operator">|</span> <a href="varint.html#PBSomeSVarint"><span class="Identifier">PBSomeSVarint</span></a><span class="Other">)</span><span class="Other">)</span><span class="Other">:</span> <a href="varint.html#VarintResult"><span class="Identifier">VarintResult</span></a><span class="Other">[</span><span class="Identifier">void</span><span class="Other">]</span> {.
<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Decode signed integer (<tt class="docutils literal"><span class="pre">int32</span></tt> or <tt class="docutils literal"><span class="pre">int64</span></tt>) from buffer <tt class="docutils literal"><span class="pre">pbytes</span></tt> and store it to <tt class="docutils literal"><span class="pre">outval</span></tt>.</p>
<p>On success <tt class="docutils literal"><span class="pre">outlen</span></tt> will be set to number of bytes processed while decoding signed varint.</p>
<p>If array <tt class="docutils literal"><span class="pre">pbytes</span></tt> is empty, <tt class="docutils literal"><span class="pre">Incomplete</span></tt> error will be returned.</p>
<p>If there not enough bytes available in array <tt class="docutils literal"><span class="pre">pbytes</span></tt> to decode <tt class="docutils literal"><span class="pre"><span class="Identifier">signed</span> <span class="Identifier">varint</span></span></tt>, <tt class="docutils literal"><span class="pre">Incomplete</span></tt> error will be returned.</p>
<p>If encoded value can produce integer overflow, <tt class="docutils literal"><span class="pre">Overflow</span></tt> error will be returned.</p>
<p>Note, when decoding 10th byte of 64bit integer only 1 bit from byte will be decoded, all other bits will be ignored. When decoding 5th byte of 32bit integer only 4 bits from byte will be decoded, all other bits will be ignored.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L183"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L183" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getUVarint,typedesc[T],openArray[byte],int,SomeUVarint" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getUVarint%2Ctypedesc%5BT%5D%2CopenArray%5Bbyte%5D%2Cint%2CSomeUVarint"><span class="Identifier">getUVarint</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="varint.html#PB"><span class="Identifier">PB</span></a> <span class="Operator">|</span> <a href="varint.html#LP"><span class="Identifier">LP</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">vtype</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">pbytes</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">;</span>
<span class="Identifier">outlen</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">int</span><span class="Other">;</span> <span class="Identifier">outval</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="varint.html#SomeUVarint"><span class="Identifier">SomeUVarint</span></a><span class="Other">)</span><span class="Other">:</span> <a href="varint.html#VarintResult"><span class="Identifier">VarintResult</span></a><span class="Other">[</span>
<span class="Identifier">void</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Decode <tt class="docutils literal"><span class="pre"><span class="Identifier">unsigned</span> <span class="Identifier">varint</span></span></tt> from buffer <tt class="docutils literal"><span class="pre">pbytes</span></tt> and store it to <tt class="docutils literal"><span class="pre">outval</span></tt>. On success <tt class="docutils literal"><span class="pre">outlen</span></tt> will be set to number of bytes processed while decoding <tt class="docutils literal"><span class="pre"><span class="Identifier">unsigned</span> <span class="Identifier">varint</span></span></tt>.</p>
<p>If array <tt class="docutils literal"><span class="pre">pbytes</span></tt> is empty, <tt class="docutils literal"><span class="pre">Incomplete</span></tt> error will be returned.</p>
<p>If there not enough bytes available in array <tt class="docutils literal"><span class="pre">pbytes</span></tt> to decode <tt class="docutils literal"><span class="pre"><span class="Identifier">unsigned</span> <span class="Identifier">varint</span></span></tt>, <tt class="docutils literal"><span class="pre">Incomplete</span></tt> error will be returned.</p>
<p>If encoded value can produce integer overflow, <tt class="docutils literal"><span class="pre">Overflow</span></tt> error will be returned.</p>
<p>Google ProtoBuf When decoding 10th byte of Google Protobuf's 64bit integer only 1 bit from byte will be decoded, all other bits will be ignored. When decoding 5th byte of 32bit integer only 4 bits from byte will be decoded, all other bits will be ignored.</p>
<p>LibP2P When decoding 5th byte of 32bit integer only 4 bits from byte will be decoded, all other bits will be ignored.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L105"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L105" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="getVarint,typedesc[T],openArray[byte],int,SomeVarint" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#getVarint%2Ctypedesc%5BT%5D%2CopenArray%5Bbyte%5D%2Cint%2CSomeVarint"><span class="Identifier">getVarint</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="varint.html#PB"><span class="Identifier">PB</span></a> <span class="Operator">|</span> <a href="varint.html#LP"><span class="Identifier">LP</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">vtype</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">pbytes</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">;</span>
<span class="Identifier">nbytes</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">int</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="varint.html#SomeVarint"><span class="Identifier">SomeVarint</span></a><span class="Other">)</span><span class="Other">:</span> <a href="varint.html#VarintResult"><span class="Identifier">VarintResult</span></a><span class="Other">[</span>
<span class="Identifier">void</span><span class="Other">]</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L250"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L250" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="putSVarint,openArray[byte],int," class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#putSVarint%2CopenArray%5Bbyte%5D%2Cint%2C"><span class="Identifier">putSVarint</span></a><span class="Other">(</span><span class="Identifier">pbytes</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">outsize</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">int</span><span class="Other">;</span>
<span class="Identifier">outval</span><span class="Other">:</span> <span class="Other">(</span><a href="varint.html#PBZigVarint"><span class="Identifier">PBZigVarint</span></a> <span class="Operator">|</span> <a href="varint.html#PBSomeSVarint"><span class="Identifier">PBSomeSVarint</span></a><span class="Other">)</span><span class="Other">)</span><span class="Other">:</span> <a href="varint.html#VarintResult"><span class="Identifier">VarintResult</span></a><span class="Other">[</span><span class="Identifier">void</span><span class="Other">]</span> {.
<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Encode signed integer <tt class="docutils literal"><span class="pre">outval</span></tt> using ProtoBuffer's zigzag encoding (<tt class="docutils literal"><span class="pre">sint32</span></tt> or <tt class="docutils literal"><span class="pre">sint64</span></tt>) and store it to array <tt class="docutils literal"><span class="pre">pbytes</span></tt>.</p>
<p>On success <tt class="docutils literal"><span class="pre">outlen</span></tt> will hold number of bytes (octets) used to encode unsigned integer <tt class="docutils literal"><span class="pre">v</span></tt>.</p>
<p>If there not enough bytes available in buffer <tt class="docutils literal"><span class="pre">pbytes</span></tt>, <tt class="docutils literal"><span class="pre">Incomplete</span></tt> error will be returned and <tt class="docutils literal"><span class="pre">outlen</span></tt> will be set to number of bytes required.</p>
<p>Maximum encoded length of 64bit integer is 10 octets. Maximum encoded length of 32bit integer is 5 octets.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L213"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L213" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="putUVarint,typedesc[T],openArray[byte],int,SomeUVarint" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#putUVarint%2Ctypedesc%5BT%5D%2CopenArray%5Bbyte%5D%2Cint%2CSomeUVarint"><span class="Identifier">putUVarint</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="varint.html#PB"><span class="Identifier">PB</span></a> <span class="Operator">|</span> <a href="varint.html#LP"><span class="Identifier">LP</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">vtype</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">pbytes</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">;</span>
<span class="Identifier">outlen</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">int</span><span class="Other">;</span> <span class="Identifier">outval</span><span class="Other">:</span> <a href="varint.html#SomeUVarint"><span class="Identifier">SomeUVarint</span></a><span class="Other">)</span><span class="Other">:</span> <a href="varint.html#VarintResult"><span class="Identifier">VarintResult</span></a><span class="Other">[</span>
<span class="Identifier">void</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Encode <tt class="docutils literal"><span class="pre"><span class="Identifier">unsigned</span> <span class="Identifier">varint</span></span></tt> <tt class="docutils literal"><span class="pre">outval</span></tt> and store it to array <tt class="docutils literal"><span class="pre">pbytes</span></tt>.</p>
<p>On success <tt class="docutils literal"><span class="pre">outlen</span></tt> will hold number of bytes (octets) used to encode unsigned integer <tt class="docutils literal"><span class="pre">v</span></tt>.</p>
<p>If there not enough bytes available in buffer <tt class="docutils literal"><span class="pre">pbytes</span></tt>, <tt class="docutils literal"><span class="pre">Incomplete</span></tt> error will be returned and <tt class="docutils literal"><span class="pre">outlen</span></tt> will be set to number of bytes required.</p>
<p>Google ProtoBuf Maximum encoded length of 64bit integer is 10 octets. Maximum encoded length of 32bit integer is 5 octets.</p>
<p>LibP2P Maximum encoded length of 63bit integer is 9 octets. Maximum encoded length of 32bit integer is 5 octets.</p>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L151"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L151" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="putVarint,typedesc[T],openArray[byte],int,SomeVarint" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#putVarint%2Ctypedesc%5BT%5D%2CopenArray%5Bbyte%5D%2Cint%2CSomeVarint"><span class="Identifier">putVarint</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="varint.html#PB"><span class="Identifier">PB</span></a> <span class="Operator">|</span> <a href="varint.html#LP"><span class="Identifier">LP</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">vtype</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">pbytes</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">byte</span><span class="Other">]</span><span class="Other">;</span>
<span class="Identifier">nbytes</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">int</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <a href="varint.html#SomeVarint"><span class="Identifier">SomeVarint</span></a><span class="Other">)</span><span class="Other">:</span> <a href="varint.html#VarintResult"><span class="Identifier">VarintResult</span></a><span class="Other">[</span>
<span class="Identifier">void</span><span class="Other">]</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L233"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L233" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
<div id="vsizeof,SomeVarint" class="tohide">
<dt><pre><span class="Keyword">proc</span> <a href="#vsizeof%2CSomeVarint"><span class="Identifier">vsizeof</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <a href="varint.html#SomeVarint"><span class="Identifier">SomeVarint</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">int</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Returns number of bytes required to encode integer <tt class="docutils literal"><span class="pre">x</span></tt> as varint.
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L101"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L101" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
</dl></div>
<div class="section" id="18">
<h1><a class="toc-backref" href="#18">Templates</a></h1>
<dl class="item">
<div id="toBytes.t,typedesc[PB],PBSomeVarint" class="tohide">
<dt><pre><span class="Keyword">template</span> <a href="#toBytes.t%2Ctypedesc%5BPB%5D%2CPBSomeVarint"><span class="Identifier">toBytes</span></a><span class="Other">(</span><span class="Identifier">vtype</span><span class="Other">:</span> <span class="Identifier">typedesc</span><span class="Other">[</span><a href="varint.html#PB"><span class="Identifier">PB</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <a href="varint.html#PBSomeVarint"><span class="Identifier">PBSomeVarint</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">auto</span></pre></dt>
<dd>
&nbsp;&nbsp;<a
href="https://github.com/status-im/nim-libp2p/tree/ma-pb-repeated-field/libp2p/varint.nim#L268"
class="link-seesrc" target="_blank">Source</a>
&nbsp;&nbsp;<a href="https://github.com/status-im/nim-libp2p/edit/devel/libp2p/varint.nim#L268" class="link-seesrc" target="_blank" >Edit</a>
</dd>
</div>
</dl></div>
</div>
</div>
<div class="row">
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2023-04-13 10:58:57 UTC</small>
</div>
</div>
</div>
</div>
</body>
</html>

File diff suppressed because one or more lines are too long