This commit is contained in:
Jenkins 2021-05-11 09:46:38 +00:00
parent 0bea08df19
commit 9e0defbb2d
33 changed files with 314 additions and 238 deletions

View File

@ -4,17 +4,17 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Nimbus Libraries</title>
<meta name="description" content="Ethereum 2.0 utilities and more">
<meta name="generator" content="VuePress 1.3.1">
<meta name="generator" content="VuePress 1.8.2">
<link rel="icon" href="/assets/img/logo.png">
<meta name="description" content="Ethereum 2.0 utilities and more">
<link rel="preload" href="/assets/css/0.styles.1d3235b8.css" as="style"><link rel="preload" href="/assets/js/app.0bbcba5f.js" as="script"><link rel="preload" href="/assets/js/4.27329ebd.js" as="script"><link rel="prefetch" href="/assets/js/10.2c46fdf3.js"><link rel="prefetch" href="/assets/js/11.bbf981b9.js"><link rel="prefetch" href="/assets/js/12.af14dcd6.js"><link rel="prefetch" href="/assets/js/13.c624f59e.js"><link rel="prefetch" href="/assets/js/2.8e6705b7.js"><link rel="prefetch" href="/assets/js/3.8d00273c.js"><link rel="prefetch" href="/assets/js/5.80ea750d.js"><link rel="prefetch" href="/assets/js/6.ccddad9d.js"><link rel="prefetch" href="/assets/js/7.11707fb6.js"><link rel="prefetch" href="/assets/js/8.9a0afdb5.js"><link rel="prefetch" href="/assets/js/9.40f78cab.js">
<link rel="stylesheet" href="/assets/css/0.styles.1d3235b8.css">
<link rel="preload" href="/assets/css/0.styles.74783a08.css" as="style"><link rel="preload" href="/assets/js/app.b6b895fe.js" as="script"><link rel="preload" href="/assets/js/6.7db49fe2.js" as="script"><link rel="prefetch" href="/assets/js/10.a7e5f96d.js"><link rel="prefetch" href="/assets/js/11.b620ddcc.js"><link rel="prefetch" href="/assets/js/12.cf1bd068.js"><link rel="prefetch" href="/assets/js/13.9dfac9d9.js"><link rel="prefetch" href="/assets/js/14.1ce3f7fe.js"><link rel="prefetch" href="/assets/js/2.fd7e9e0b.js"><link rel="prefetch" href="/assets/js/3.c5869ccf.js"><link rel="prefetch" href="/assets/js/4.b9b777bd.js"><link rel="prefetch" href="/assets/js/5.073c37d9.js"><link rel="prefetch" href="/assets/js/7.852d0869.js"><link rel="prefetch" href="/assets/js/8.b8ee59fd.js"><link rel="prefetch" href="/assets/js/9.249d32d4.js">
<link rel="stylesheet" href="/assets/css/0.styles.74783a08.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><div class="theme-default-content"><h1>404</h1> <blockquote>There's nothing here.</blockquote> <a href="/" class="router-link-active">
Take me home.
</a></div></div><div class="global-ui"></div></div>
<script src="/assets/js/app.0bbcba5f.js" defer></script><script src="/assets/js/4.27329ebd.js" defer></script>
<script src="/assets/js/app.b6b895fe.js" defer></script><script src="/assets/js/6.7db49fe2.js" defer></script>
</body>
</html>

View File

@ -4,12 +4,12 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>About | Nimbus Libraries</title>
<meta name="description" content="Ethereum 2.0 utilities and more">
<meta name="generator" content="VuePress 1.3.1">
<meta name="generator" content="VuePress 1.8.2">
<link rel="icon" href="/assets/img/logo.png">
<meta name="description" content="Ethereum 2.0 utilities and more">
<link rel="preload" href="/assets/css/0.styles.1d3235b8.css" as="style"><link rel="preload" href="/assets/js/app.0bbcba5f.js" as="script"><link rel="preload" href="/assets/js/2.8e6705b7.js" as="script"><link rel="preload" href="/assets/js/6.ccddad9d.js" as="script"><link rel="prefetch" href="/assets/js/10.2c46fdf3.js"><link rel="prefetch" href="/assets/js/11.bbf981b9.js"><link rel="prefetch" href="/assets/js/12.af14dcd6.js"><link rel="prefetch" href="/assets/js/13.c624f59e.js"><link rel="prefetch" href="/assets/js/3.8d00273c.js"><link rel="prefetch" href="/assets/js/4.27329ebd.js"><link rel="prefetch" href="/assets/js/5.80ea750d.js"><link rel="prefetch" href="/assets/js/7.11707fb6.js"><link rel="prefetch" href="/assets/js/8.9a0afdb5.js"><link rel="prefetch" href="/assets/js/9.40f78cab.js">
<link rel="stylesheet" href="/assets/css/0.styles.1d3235b8.css">
<link rel="preload" href="/assets/css/0.styles.74783a08.css" as="style"><link rel="preload" href="/assets/js/app.b6b895fe.js" as="script"><link rel="preload" href="/assets/js/2.fd7e9e0b.js" as="script"><link rel="preload" href="/assets/js/8.b8ee59fd.js" as="script"><link rel="prefetch" href="/assets/js/10.a7e5f96d.js"><link rel="prefetch" href="/assets/js/11.b620ddcc.js"><link rel="prefetch" href="/assets/js/12.cf1bd068.js"><link rel="prefetch" href="/assets/js/13.9dfac9d9.js"><link rel="prefetch" href="/assets/js/14.1ce3f7fe.js"><link rel="prefetch" href="/assets/js/3.c5869ccf.js"><link rel="prefetch" href="/assets/js/4.b9b777bd.js"><link rel="prefetch" href="/assets/js/5.073c37d9.js"><link rel="prefetch" href="/assets/js/6.7db49fe2.js"><link rel="prefetch" href="/assets/js/7.852d0869.js"><link rel="prefetch" href="/assets/js/9.249d32d4.js">
<link rel="stylesheet" href="/assets/css/0.styles.74783a08.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/assets/img/logo.png" alt="Nimbus Libraries" class="logo"> <span class="site-name can-hide">Nimbus Libraries</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/lib/nim-libp2p/" class="nav-link">
@ -36,7 +36,7 @@
Eth
</a></div><div class="nav-item"><a href="/lib/nim-stew/" class="nav-link">
Stew
</a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>About</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/about.html#what-is-nimbus" class="sidebar-link">What is Nimbus?</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/about.html#why-not-nimdoc" class="sidebar-link">Why not Nimdoc?</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/about.html#contributing" class="sidebar-link">Contributing</a><ul class="sidebar-sub-headers"></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="about"><a href="#about" class="header-anchor">#</a> About</h1> <p>This documentation suite was created as a comprehensive guide for using the Nim libraries produced by the Nimbus team at Status.im.</p> <h2 id="what-is-nimbus"><a href="#what-is-nimbus" class="header-anchor">#</a> What is Nimbus?</h2> <p><a href="https://nimbus.status.im" target="_blank" rel="noopener noreferrer">Nimbus<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a> is an Ethereum 2.0 client, but these libraries are designed to be used outside of that context too. If your project needs good cryptography or verbose logging output, these libraries should fit the bill nicely.</p> <p>You do not need to be a Nimbus user or developer to make use of these libraries.</p> <h2 id="why-not-nimdoc"><a href="#why-not-nimdoc" class="header-anchor">#</a> Why not Nimdoc?</h2> <p>We actually do use Nimdoc for the API reference included in each library's documentation on this site. However, Nimdoc's template isn't the easiest to modify and it can produce some buggy results, so we use its JSON output to feed the API docs into this tome, and we use Vuepress for the rest of the functionality, like custom layouts, styling, SEO support, searchability, and of course - custom documentation support, like guides, tutorials, references, and more.</p> <h2 id="contributing"><a href="#contributing" class="header-anchor">#</a> Contributing</h2> <p>You can contribute to these docs by submitting issues or pull requests in the official repository at <a href="https://github.com/status-im/nimbus-libs-site" target="_blank" rel="noopener noreferrer">status-im/nimbus-libs-site<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a>.</p> <p>Keep in mind the following:</p> <ul><li>the API reference is generated from individual libraries. Thus, if you notice a mistake in the API reference, to submit a fix you should submit a PR to the library in question and fix its docblock.</li> <li>the guides are curated and not everything that's written about the libraries will be included here.</li></ul></div> <footer class="page-edit"><!----> <!----></footer> <!----> </main></div><div class="global-ui"></div></div>
<script src="/assets/js/app.0bbcba5f.js" defer></script><script src="/assets/js/2.8e6705b7.js" defer></script><script src="/assets/js/6.ccddad9d.js" defer></script>
</a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>About</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/about.html#what-is-nimbus" class="sidebar-link">What is Nimbus?</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/about.html#why-not-nimdoc" class="sidebar-link">Why not Nimdoc?</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/about.html#contributing" class="sidebar-link">Contributing</a><ul class="sidebar-sub-headers"></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="about"><a href="#about" class="header-anchor">#</a> About</h1> <p>This documentation suite was created as a comprehensive guide for using the Nim libraries produced by the Nimbus team at Status.im.</p> <h2 id="what-is-nimbus"><a href="#what-is-nimbus" class="header-anchor">#</a> What is Nimbus?</h2> <p><a href="https://nimbus.status.im" target="_blank" rel="noopener noreferrer">Nimbus<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> is an Ethereum 2.0 client, but these libraries are designed to be used outside of that context too. If your project needs good cryptography or verbose logging output, these libraries should fit the bill nicely.</p> <p>You do not need to be a Nimbus user or developer to make use of these libraries.</p> <h2 id="why-not-nimdoc"><a href="#why-not-nimdoc" class="header-anchor">#</a> Why not Nimdoc?</h2> <p>We actually do use Nimdoc for the API reference included in each library's documentation on this site. However, Nimdoc's template isn't the easiest to modify and it can produce some buggy results, so we use its JSON output to feed the API docs into this tome, and we use Vuepress for the rest of the functionality, like custom layouts, styling, SEO support, searchability, and of course - custom documentation support, like guides, tutorials, references, and more.</p> <h2 id="contributing"><a href="#contributing" class="header-anchor">#</a> Contributing</h2> <p>You can contribute to these docs by submitting issues or pull requests in the official repository at <a href="https://github.com/status-im/nimbus-libs-site" target="_blank" rel="noopener noreferrer">status-im/nimbus-libs-site<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>.</p> <p>Keep in mind the following:</p> <ul><li>the API reference is generated from individual libraries. Thus, if you notice a mistake in the API reference, to submit a fix you should submit a PR to the library in question and fix its docblock.</li> <li>the guides are curated and not everything that's written about the libraries will be included here.</li></ul></div> <footer class="page-edit"><!----> <!----></footer> <!----> </main></div><div class="global-ui"></div></div>
<script src="/assets/js/app.b6b895fe.js" defer></script><script src="/assets/js/2.fd7e9e0b.js" defer></script><script src="/assets/js/8.b8ee59fd.js" defer></script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
assets/js/10.a7e5f96d.js Normal file

File diff suppressed because one or more lines are too long

1
assets/js/11.b620ddcc.js Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
assets/js/12.cf1bd068.js Normal file

File diff suppressed because one or more lines are too long

1
assets/js/13.9dfac9d9.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[13],{142:function(n,w,o){}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
assets/js/2.fd7e9e0b.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[3],{159:function(t,e,n){},202:function(t,e,n){"use strict";var i=n(159);n.n(i).a},210:function(t,e,n){"use strict";n.r(e);var i={functional:!0,props:{type:{type:String,default:"tip"},text:String,vertical:{type:String,default:"top"}},render:function(t,e){var n=e.props,i=e.slots;return t("span",{class:["badge",n.type],style:{verticalAlign:n.vertical}},n.text||i().default)}},r=(n(202),n(28)),a=Object(r.a)(i,void 0,void 0,!1,null,"15b7b770",null);e.default=a.exports}}]);

1
assets/js/3.c5869ccf.js Normal file
View File

@ -0,0 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[3],{329:function(t,e,n){},357:function(t,e,n){"use strict";n(329)},372:function(t,e,n){"use strict";n.r(e);var i={functional:!0,props:{type:{type:String,default:"tip"},text:String,vertical:{type:String,default:"top"}},render:function(t,e){var n=e.props,i=e.slots;return t("span",{class:["badge",n.type],style:{verticalAlign:n.vertical}},n.text||i().default)}},r=(n(357),n(44)),p=Object(r.a)(i,void 0,void 0,!1,null,"15b7b770",null);e.default=p.exports}}]);

1
assets/js/4.b9b777bd.js Normal file
View File

@ -0,0 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{330:function(t,e,a){},358:function(t,e,a){"use strict";a(330)},362:function(t,e,a){"use strict";a.r(e);var n={name:"CodeBlock",props:{title:{type:String,required:!0},active:{type:Boolean,default:!1}},mounted:function(){this.$parent&&this.$parent.loadTabs&&this.$parent.loadTabs()}},i=(a(358),a(44)),s=Object(i.a)(n,(function(){var t=this.$createElement;return(this._self._c||t)("div",{staticClass:"theme-code-block",class:{"theme-code-block__active":this.active}},[this._t("default")],2)}),[],!1,null,"759a7d02",null);e.default=s.exports}}]);

1
assets/js/5.073c37d9.js Normal file
View File

@ -0,0 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{331:function(e,t,a){},359:function(e,t,a){"use strict";a(331)},363:function(e,t,a){"use strict";a.r(t);a(66),a(27),a(95),a(96);var o={name:"CodeGroup",data:function(){return{codeTabs:[],activeCodeTabIndex:-1}},watch:{activeCodeTabIndex:function(e){this.activateCodeTab(e)}},mounted:function(){this.loadTabs()},methods:{changeCodeTab:function(e){this.activeCodeTabIndex=e},loadTabs:function(){var e=this;this.codeTabs=(this.$slots.default||[]).filter((function(e){return Boolean(e.componentOptions)})).map((function(t,a){return""===t.componentOptions.propsData.active&&(e.activeCodeTabIndex=a),{title:t.componentOptions.propsData.title,elm:t.elm}})),-1===this.activeCodeTabIndex&&this.codeTabs.length>0&&(this.activeCodeTabIndex=0),this.activateCodeTab(0)},activateCodeTab:function(e){this.codeTabs.forEach((function(e){e.elm&&e.elm.classList.remove("theme-code-block__active")})),this.codeTabs[e].elm&&this.codeTabs[e].elm.classList.add("theme-code-block__active")}}},n=(a(359),a(44)),c=Object(n.a)(o,(function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("ClientOnly",[a("div",{staticClass:"theme-code-group"},[a("div",{staticClass:"theme-code-group__nav"},[a("ul",{staticClass:"theme-code-group__ul"},e._l(e.codeTabs,(function(t,o){return a("li",{key:t.title,staticClass:"theme-code-group__li"},[a("button",{staticClass:"theme-code-group__nav-tab",class:{"theme-code-group__nav-tab-active":o===e.activeCodeTabIndex},on:{click:function(t){return e.changeCodeTab(o)}}},[e._v("\n "+e._s(t.title)+"\n ")])])})),0)]),e._v(" "),e._t("default"),e._v(" "),e.codeTabs.length<1?a("pre",{staticClass:"pre-blank"},[e._v("// Make sure to add code blocks to your code group")]):e._e()],2)])}),[],!1,null,"deefee04",null);t.default=c.exports}}]);

View File

@ -1 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{204:function(t,e,s){"use strict";s.r(e);var n=["There's nothing here.","How did we get here?","That's a Four-Oh-Four.","Looks like we've got some broken links."],o={methods:{getMsg:function(){return n[Math.floor(Math.random()*n.length)]}}},i=s(28),h=Object(i.a)(o,(function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"theme-container"},[e("div",{staticClass:"theme-default-content"},[e("h1",[this._v("404")]),this._v(" "),e("blockquote",[this._v(this._s(this.getMsg()))]),this._v(" "),e("RouterLink",{attrs:{to:"/"}},[this._v("\n Take me home.\n ")])],1)])}),[],!1,null,null,null);e.default=h.exports}}]);
(window.webpackJsonp=window.webpackJsonp||[]).push([[6],{361:function(t,e,s){"use strict";s.r(e);var n=["There's nothing here.","How did we get here?","That's a Four-Oh-Four.","Looks like we've got some broken links."],o={methods:{getMsg:function(){return n[Math.floor(Math.random()*n.length)]}}},i=s(44),h=Object(i.a)(o,(function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"theme-container"},[e("div",{staticClass:"theme-default-content"},[e("h1",[this._v("404")]),this._v(" "),e("blockquote",[this._v(this._s(this.getMsg()))]),this._v(" "),e("RouterLink",{attrs:{to:"/"}},[this._v("\n Take me home.\n ")])],1)])}),[],!1,null,null,null);e.default=h.exports}}]);

View File

@ -1 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{206:function(t,e,a){"use strict";a.r(e);var r=a(28),s=Object(r.a)({},(function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"how-the-documentation-is-organized"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#how-the-documentation-is-organized"}},[t._v("#")]),t._v(" How the Documentation is organized")]),t._v(" "),a("p",[t._v("Documentation is organized into four categories: tutorials, overviews, API references and how-to guides.")]),t._v(" "),a("ul",[a("li",[t._v("Tutorials take you by the hand through a series of steps to put a library / module to use. Start here if youre new to a library.")]),t._v(" "),a("li",[t._v("Overviews discuss key topics and concepts at a fairly high level and provide useful background information and explanation. Those are the things you usually see in READMEs of repos.")]),t._v(" "),a("li",[t._v("API references contain technical reference for APIs and other aspects of a module's machinery. They describe how it works and how to use it but assume that you have a basic understanding of key concepts. These are auto-generated from the code, and depend heavily on the programmer's verbosity and the technical writer's persistence.")]),t._v(" "),a("li",[t._v("How-to guides are recipes. They guide you through the steps involved in addressing key problems and use-cases. They are more advanced, shorter, and more specific than tutorials and assume some previous knowledge.")])]),t._v(" "),a("h2",{attrs:{id:"get-started"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#get-started"}},[t._v("#")]),t._v(" Get Started")]),t._v(" "),a("p",[t._v("Use the search field in the header, or find a desired library in the sections below. Each library has its own documentation with a full API reference and guides. If you'd like to contribute to these docs with your own work or some corrections, please file issues or PRs "),a("a",{attrs:{href:"https://github.com/status-im/nimbus-libs-site",target:"_blank",rel:"noopener noreferrer"}},[t._v("in the Github repo"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("div",{staticClass:"theorem"},[a("p",{staticClass:"title"},[a("a",{attrs:{href:"/lib/nim-libp2p/"}},[t._v("libp2p")]),a("Badge",{attrs:{text:"libp2p"}}),a("Badge",{attrs:{text:"networking"}}),a("Badge",{attrs:{text:"development",type:"warn"}})],1),a("p",[t._v("nim-libp2p is an implementation of the libp2p modular peer-to-peer networking stack based on Chronos")])]),a("div",{staticClass:"theorem"},[a("p",{staticClass:"title"},[a("a",{attrs:{href:"/lib/nim-chronicles/"}},[t._v("Chronicles")]),a("Badge",{attrs:{text:"logging"}}),a("Badge",{attrs:{text:"stable"}})],1),a("p",[t._v("Chronicles is a library for structured logging. It adheres to the philosophy that log files shouldn't be based on formatted text strings, but rather on well-defined event records with arbitrary properties that are easy to read for both humans and machines.")])]),a("div",{staticClass:"theorem"},[a("p",{staticClass:"title"},[a("a",{attrs:{href:"/lib/nimcrypto/"}},[t._v("Nimcrypto")]),a("Badge",{attrs:{text:"cryptography"}}),a("Badge",{attrs:{text:"development",type:"warn"}})],1),a("p",[t._v("Nimcrypto is Nim's cryptographic library. It implements several popular cryptographic algorithms and their tests with some "),a("a",{attrs:{href:"https://github.com/cheatfate/nimcrypto/tree/master/examples",target:"_blank",rel:"noopener noreferrer"}},[t._v("examples"),a("OutboundLink")],1),t._v(".")])]),a("div",{staticClass:"theorem"},[a("p",{staticClass:"title"},[a("a",{attrs:{href:"/lib/nim-chronos/"}},[t._v("Chronos")]),a("Badge",{attrs:{text:"async"}}),a("Badge",{attrs:{text:"stable"}}),a("Badge",{attrs:{text:"networking"}})],1),a("p",[t._v("Chronos is an efficient library for asynchronous programming and an alternative to Nim's asyncdispatch.")])]),a("div",{staticClass:"theorem"},[a("p",{staticClass:"title"},[a("a",{attrs:{href:"/lib/nim-eth/"}},[t._v("Eth")]),a("Badge",{attrs:{text:"eth"}}),a("Badge",{attrs:{text:"keys"}}),a("Badge",{attrs:{text:"bloom"}}),a("Badge",{attrs:{text:"rlp"}}),a("Badge",{attrs:{text:"encoding"}}),a("Badge",{attrs:{text:"formatting"}}),a("Badge",{attrs:{text:"cryptography"}}),a("Badge",{attrs:{text:"development",type:"warn"}})],1),a("p",[t._v("Ethereum-related utilities written in Nim. Includes things like Bloom filters, private/public key utilities, devp2p, RLP, and more.")])]),a("div",{staticClass:"theorem"},[a("p",{staticClass:"title"},[a("a",{attrs:{href:"/lib/nim-stew/"}},[t._v("Stew")]),a("Badge",{attrs:{text:"encoding"}}),a("Badge",{attrs:{text:"formatting"}}),a("Badge",{attrs:{text:"development",type:"warn"}}),a("Badge",{attrs:{text:"utilities"}})],1),a("p",[t._v("General-purpose utilities and standard library extensions")])])])}),[],!1,null,null,null);e.default=s.exports}}]);
(window.webpackJsonp=window.webpackJsonp||[]).push([[7],{364:function(t,e,a){"use strict";a.r(e);var r=a(44),s=Object(r.a)({},(function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"how-the-documentation-is-organized"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#how-the-documentation-is-organized"}},[t._v("#")]),t._v(" How the Documentation is organized")]),t._v(" "),a("p",[t._v("Documentation is organized into four categories: tutorials, overviews, API references and how-to guides.")]),t._v(" "),a("ul",[a("li",[t._v("Tutorials take you by the hand through a series of steps to put a library / module to use. Start here if youre new to a library.")]),t._v(" "),a("li",[t._v("Overviews discuss key topics and concepts at a fairly high level and provide useful background information and explanation. Those are the things you usually see in READMEs of repos.")]),t._v(" "),a("li",[t._v("API references contain technical reference for APIs and other aspects of a module's machinery. They describe how it works and how to use it but assume that you have a basic understanding of key concepts. These are auto-generated from the code, and depend heavily on the programmer's verbosity and the technical writer's persistence.")]),t._v(" "),a("li",[t._v("How-to guides are recipes. They guide you through the steps involved in addressing key problems and use-cases. They are more advanced, shorter, and more specific than tutorials and assume some previous knowledge.")])]),t._v(" "),a("h2",{attrs:{id:"get-started"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#get-started"}},[t._v("#")]),t._v(" Get Started")]),t._v(" "),a("p",[t._v("Use the search field in the header, or find a desired library in the sections below. Each library has its own documentation with a full API reference and guides. If you'd like to contribute to these docs with your own work or some corrections, please file issues or PRs "),a("a",{attrs:{href:"https://github.com/status-im/nimbus-libs-site",target:"_blank",rel:"noopener noreferrer"}},[t._v("in the Github repo"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("div",{staticClass:"theorem"},[a("p",{staticClass:"title"},[a("a",{attrs:{href:"/lib/nim-libp2p/"}},[t._v("libp2p")]),a("Badge",{attrs:{text:"libp2p"}}),a("Badge",{attrs:{text:"networking"}}),a("Badge",{attrs:{text:"development",type:"warn"}})],1),a("p",[t._v("nim-libp2p is an implementation of the libp2p modular peer-to-peer networking stack based on Chronos")])]),a("div",{staticClass:"theorem"},[a("p",{staticClass:"title"},[a("a",{attrs:{href:"/lib/nim-chronicles/"}},[t._v("Chronicles")]),a("Badge",{attrs:{text:"logging"}}),a("Badge",{attrs:{text:"stable"}})],1),a("p",[t._v("Chronicles is a library for structured logging. It adheres to the philosophy that log files shouldn't be based on formatted text strings, but rather on well-defined event records with arbitrary properties that are easy to read for both humans and machines.")])]),a("div",{staticClass:"theorem"},[a("p",{staticClass:"title"},[a("a",{attrs:{href:"/lib/nimcrypto/"}},[t._v("Nimcrypto")]),a("Badge",{attrs:{text:"cryptography"}}),a("Badge",{attrs:{text:"development",type:"warn"}})],1),a("p",[t._v("Nimcrypto is Nim's cryptographic library. It implements several popular cryptographic algorithms and their tests with some "),a("a",{attrs:{href:"https://github.com/cheatfate/nimcrypto/tree/master/examples",target:"_blank",rel:"noopener noreferrer"}},[t._v("examples"),a("OutboundLink")],1),t._v(".")])]),a("div",{staticClass:"theorem"},[a("p",{staticClass:"title"},[a("a",{attrs:{href:"/lib/nim-chronos/"}},[t._v("Chronos")]),a("Badge",{attrs:{text:"async"}}),a("Badge",{attrs:{text:"stable"}}),a("Badge",{attrs:{text:"networking"}})],1),a("p",[t._v("Chronos is an efficient library for asynchronous programming and an alternative to Nim's asyncdispatch.")])]),a("div",{staticClass:"theorem"},[a("p",{staticClass:"title"},[a("a",{attrs:{href:"/lib/nim-eth/"}},[t._v("Eth")]),a("Badge",{attrs:{text:"eth"}}),a("Badge",{attrs:{text:"keys"}}),a("Badge",{attrs:{text:"bloom"}}),a("Badge",{attrs:{text:"rlp"}}),a("Badge",{attrs:{text:"encoding"}}),a("Badge",{attrs:{text:"formatting"}}),a("Badge",{attrs:{text:"cryptography"}}),a("Badge",{attrs:{text:"development",type:"warn"}})],1),a("p",[t._v("Ethereum-related utilities written in Nim. Includes things like Bloom filters, private/public key utilities, devp2p, RLP, and more.")])]),a("div",{staticClass:"theorem"},[a("p",{staticClass:"title"},[a("a",{attrs:{href:"/lib/nim-stew/"}},[t._v("Stew")]),a("Badge",{attrs:{text:"encoding"}}),a("Badge",{attrs:{text:"formatting"}}),a("Badge",{attrs:{text:"development",type:"warn"}}),a("Badge",{attrs:{text:"utilities"}})],1),a("p",[t._v("General-purpose utilities and standard library extensions")])])])}),[],!1,null,null,null);e.default=s.exports}}]);

View File

@ -1 +0,0 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{207:function(t,a,n){"use strict";n.r(a);var s=n(28),e=Object(s.a)({},(function(){var t=this,a=t.$createElement,n=t._self._c||a;return n("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[n("h1",{attrs:{id:"chronos"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#chronos"}},[t._v("#")]),t._v(" Chronos")]),t._v(" "),n("p",[t._v("Chronos is an efficient library for asynchronous programming and an alternative to Nim's asyncdispatch.")]),t._v(" "),n("h2",{attrs:{id:"documentation"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#documentation"}},[t._v("#")]),t._v(" Documentation")]),t._v(" "),n("p",[t._v("You can find more documentation, notes and examples in "),n("a",{attrs:{href:"https://github.com/status-im/nim-chronos/wiki",target:"_blank",rel:"noopener noreferrer"}},[t._v("Wiki"),n("OutboundLink")],1),t._v(".")]),t._v(" "),n("h2",{attrs:{id:"installation"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#installation"}},[t._v("#")]),t._v(" Installation")]),t._v(" "),n("p",[t._v("You can use Nim official package manager "),n("code",[t._v("nimble")]),t._v(" to install "),n("code",[t._v("chronos")]),t._v(". The most recent version of the library can be installed via:")]),t._v(" "),n("div",{staticClass:"language- line-numbers-mode"},[n("pre",{pre:!0,attrs:{class:"language-text"}},[n("code",[t._v("$ nimble install https://github.com/status-im/nim-chronos.git\n")])]),t._v(" "),n("div",{staticClass:"line-numbers-wrapper"},[n("span",{staticClass:"line-number"},[t._v("1")]),n("br")])]),n("h2",{attrs:{id:"todo"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#todo"}},[t._v("#")]),t._v(" TODO")]),t._v(" "),n("ul",[n("li",[t._v("Pipe/Subprocess Transports.")]),t._v(" "),n("li",[t._v("Multithreading Stream/Datagram servers")]),t._v(" "),n("li",[t._v("Future[T] cancelation")])])])}),[],!1,null,null,null);a.default=e.exports}}]);

View File

@ -1 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[6],{212:function(t,e,i){"use strict";i.r(e);var s=i(28),o=Object(s.a)({},(function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[i("h1",{attrs:{id:"about"}},[i("a",{staticClass:"header-anchor",attrs:{href:"#about"}},[t._v("#")]),t._v(" About")]),t._v(" "),i("p",[t._v("This documentation suite was created as a comprehensive guide for using the Nim libraries produced by the Nimbus team at Status.im.")]),t._v(" "),i("h2",{attrs:{id:"what-is-nimbus"}},[i("a",{staticClass:"header-anchor",attrs:{href:"#what-is-nimbus"}},[t._v("#")]),t._v(" What is Nimbus?")]),t._v(" "),i("p",[i("a",{attrs:{href:"https://nimbus.status.im",target:"_blank",rel:"noopener noreferrer"}},[t._v("Nimbus"),i("OutboundLink")],1),t._v(" is an Ethereum 2.0 client, but these libraries are designed to be used outside of that context too. If your project needs good cryptography or verbose logging output, these libraries should fit the bill nicely.")]),t._v(" "),i("p",[t._v("You do not need to be a Nimbus user or developer to make use of these libraries.")]),t._v(" "),i("h2",{attrs:{id:"why-not-nimdoc"}},[i("a",{staticClass:"header-anchor",attrs:{href:"#why-not-nimdoc"}},[t._v("#")]),t._v(" Why not Nimdoc?")]),t._v(" "),i("p",[t._v("We actually do use Nimdoc for the API reference included in each library's documentation on this site. However, Nimdoc's template isn't the easiest to modify and it can produce some buggy results, so we use its JSON output to feed the API docs into this tome, and we use Vuepress for the rest of the functionality, like custom layouts, styling, SEO support, searchability, and of course - custom documentation support, like guides, tutorials, references, and more.")]),t._v(" "),i("h2",{attrs:{id:"contributing"}},[i("a",{staticClass:"header-anchor",attrs:{href:"#contributing"}},[t._v("#")]),t._v(" Contributing")]),t._v(" "),i("p",[t._v("You can contribute to these docs by submitting issues or pull requests in the official repository at "),i("a",{attrs:{href:"https://github.com/status-im/nimbus-libs-site",target:"_blank",rel:"noopener noreferrer"}},[t._v("status-im/nimbus-libs-site"),i("OutboundLink")],1),t._v(".")]),t._v(" "),i("p",[t._v("Keep in mind the following:")]),t._v(" "),i("ul",[i("li",[t._v("the API reference is generated from individual libraries. Thus, if you notice a mistake in the API reference, to submit a fix you should submit a PR to the library in question and fix its docblock.")]),t._v(" "),i("li",[t._v("the guides are curated and not everything that's written about the libraries will be included here.")])])])}),[],!1,null,null,null);e.default=o.exports}}]);
(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{365:function(t,e,i){"use strict";i.r(e);var s=i(44),o=Object(s.a)({},(function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[i("h1",{attrs:{id:"about"}},[i("a",{staticClass:"header-anchor",attrs:{href:"#about"}},[t._v("#")]),t._v(" About")]),t._v(" "),i("p",[t._v("This documentation suite was created as a comprehensive guide for using the Nim libraries produced by the Nimbus team at Status.im.")]),t._v(" "),i("h2",{attrs:{id:"what-is-nimbus"}},[i("a",{staticClass:"header-anchor",attrs:{href:"#what-is-nimbus"}},[t._v("#")]),t._v(" What is Nimbus?")]),t._v(" "),i("p",[i("a",{attrs:{href:"https://nimbus.status.im",target:"_blank",rel:"noopener noreferrer"}},[t._v("Nimbus"),i("OutboundLink")],1),t._v(" is an Ethereum 2.0 client, but these libraries are designed to be used outside of that context too. If your project needs good cryptography or verbose logging output, these libraries should fit the bill nicely.")]),t._v(" "),i("p",[t._v("You do not need to be a Nimbus user or developer to make use of these libraries.")]),t._v(" "),i("h2",{attrs:{id:"why-not-nimdoc"}},[i("a",{staticClass:"header-anchor",attrs:{href:"#why-not-nimdoc"}},[t._v("#")]),t._v(" Why not Nimdoc?")]),t._v(" "),i("p",[t._v("We actually do use Nimdoc for the API reference included in each library's documentation on this site. However, Nimdoc's template isn't the easiest to modify and it can produce some buggy results, so we use its JSON output to feed the API docs into this tome, and we use Vuepress for the rest of the functionality, like custom layouts, styling, SEO support, searchability, and of course - custom documentation support, like guides, tutorials, references, and more.")]),t._v(" "),i("h2",{attrs:{id:"contributing"}},[i("a",{staticClass:"header-anchor",attrs:{href:"#contributing"}},[t._v("#")]),t._v(" Contributing")]),t._v(" "),i("p",[t._v("You can contribute to these docs by submitting issues or pull requests in the official repository at "),i("a",{attrs:{href:"https://github.com/status-im/nimbus-libs-site",target:"_blank",rel:"noopener noreferrer"}},[t._v("status-im/nimbus-libs-site"),i("OutboundLink")],1),t._v(".")]),t._v(" "),i("p",[t._v("Keep in mind the following:")]),t._v(" "),i("ul",[i("li",[t._v("the API reference is generated from individual libraries. Thus, if you notice a mistake in the API reference, to submit a fix you should submit a PR to the library in question and fix its docblock.")]),t._v(" "),i("li",[t._v("the guides are curated and not everything that's written about the libraries will be included here.")])])])}),[],!1,null,null,null);e.default=o.exports}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -4,17 +4,17 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Chronicles | Nimbus Libraries</title>
<meta name="description" content="Ethereum 2.0 utilities and more">
<meta name="generator" content="VuePress 1.3.1">
<meta name="generator" content="VuePress 1.8.2">
<link rel="icon" href="/assets/img/logo.png">
<meta name="description" content="Ethereum 2.0 utilities and more">
<link rel="preload" href="/assets/css/0.styles.1d3235b8.css" as="style"><link rel="preload" href="/assets/js/app.0bbcba5f.js" as="script"><link rel="preload" href="/assets/js/2.8e6705b7.js" as="script"><link rel="preload" href="/assets/js/7.11707fb6.js" as="script"><link rel="prefetch" href="/assets/js/10.2c46fdf3.js"><link rel="prefetch" href="/assets/js/11.bbf981b9.js"><link rel="prefetch" href="/assets/js/12.af14dcd6.js"><link rel="prefetch" href="/assets/js/13.c624f59e.js"><link rel="prefetch" href="/assets/js/3.8d00273c.js"><link rel="prefetch" href="/assets/js/4.27329ebd.js"><link rel="prefetch" href="/assets/js/5.80ea750d.js"><link rel="prefetch" href="/assets/js/6.ccddad9d.js"><link rel="prefetch" href="/assets/js/8.9a0afdb5.js"><link rel="prefetch" href="/assets/js/9.40f78cab.js">
<link rel="stylesheet" href="/assets/css/0.styles.1d3235b8.css">
<link rel="preload" href="/assets/css/0.styles.74783a08.css" as="style"><link rel="preload" href="/assets/js/app.b6b895fe.js" as="script"><link rel="preload" href="/assets/js/2.fd7e9e0b.js" as="script"><link rel="preload" href="/assets/js/9.249d32d4.js" as="script"><link rel="prefetch" href="/assets/js/10.a7e5f96d.js"><link rel="prefetch" href="/assets/js/11.b620ddcc.js"><link rel="prefetch" href="/assets/js/12.cf1bd068.js"><link rel="prefetch" href="/assets/js/13.9dfac9d9.js"><link rel="prefetch" href="/assets/js/14.1ce3f7fe.js"><link rel="prefetch" href="/assets/js/3.c5869ccf.js"><link rel="prefetch" href="/assets/js/4.b9b777bd.js"><link rel="prefetch" href="/assets/js/5.073c37d9.js"><link rel="prefetch" href="/assets/js/6.7db49fe2.js"><link rel="prefetch" href="/assets/js/7.852d0869.js"><link rel="prefetch" href="/assets/js/8.b8ee59fd.js">
<link rel="stylesheet" href="/assets/css/0.styles.74783a08.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/assets/img/logo.png" alt="Nimbus Libraries" class="logo"> <span class="site-name can-hide">Nimbus Libraries</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/lib/nim-libp2p/" class="nav-link">
libp2p
</a></div><div class="nav-item"><a href="/lib/nim-chronicles/" class="nav-link router-link-exact-active router-link-active">
</a></div><div class="nav-item"><a href="/lib/nim-chronicles/" aria-current="page" class="nav-link router-link-exact-active router-link-active">
Chronicles
</a></div><div class="nav-item"><a href="/lib/nimcrypto/" class="nav-link">
Nimcrypto
@ -26,7 +26,7 @@
Stew
</a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/lib/nim-libp2p/" class="nav-link">
libp2p
</a></div><div class="nav-item"><a href="/lib/nim-chronicles/" class="nav-link router-link-exact-active router-link-active">
</a></div><div class="nav-item"><a href="/lib/nim-chronicles/" aria-current="page" class="nav-link router-link-exact-active router-link-active">
Chronicles
</a></div><div class="nav-item"><a href="/lib/nimcrypto/" class="nav-link">
Nimcrypto
@ -62,7 +62,7 @@ filtering, sound alerts and more.</p> <p>The main advantage of using JSON loggin
of the log records in specialized databases which are usually able to provide
search and filtering capabilities and allow you to compute various aggregated
metrics and time-series data from the accumulated logs.</p> <p>Typical log storage choices for the above are open-source search engines such
as <a href="https://www.elastic.co/" target="_blank" rel="noopener noreferrer">ElasticSearch<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a> or specialized providers such as <a href="https://www.loggly.com/" target="_blank" rel="noopener noreferrer">Loggly<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a>.</p> <h2 id="logging-scopes"><a href="#logging-scopes" class="header-anchor">#</a> Logging Scopes</h2> <p>In the introduction, we saw <code>debug</code> and <code>info</code> as examples for logging
as <a href="https://www.elastic.co/" target="_blank" rel="noopener noreferrer">ElasticSearch<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> or specialized providers such as <a href="https://www.loggly.com/" target="_blank" rel="noopener noreferrer">Loggly<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>.</p> <h2 id="logging-scopes"><a href="#logging-scopes" class="header-anchor">#</a> Logging Scopes</h2> <p>In the introduction, we saw <code>debug</code> and <code>info</code> as examples for logging
statements. Other similar statements include <code>trace</code>, <code>notice</code>, <code>warn</code>, <code>error</code>
and <code>fatal</code>. All of these statements accept arbitrary key-value pairs.
As a short-cut, you are also allowed to specify only the name of a particular
@ -231,7 +231,7 @@ default mode for sinks logging only to files or for sinks using the json
format.</p></li></ul> <p>Current known limitations:</p> <ul><li>Chronicles will not try to detect if the standard outputs
of the program are being redirected to another program or a file.
It's typical for the colored output to be disabled in such circumstances.
(<a href="https://github.com/status-im/nim-chronicles/issues/1" target="_blank" rel="noopener noreferrer">issue<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a>)</li></ul> <h3 id="chronicles-indent"><a href="#chronicles-indent" class="header-anchor">#</a> chronicles_indent</h3> <p>This option sets the desired number of spaces that Chronicles should
(<a href="https://github.com/status-im/nim-chronicles/issues/1" target="_blank" rel="noopener noreferrer">issue<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>)</li></ul> <h3 id="chronicles-indent"><a href="#chronicles-indent" class="header-anchor">#</a> chronicles_indent</h3> <p>This option sets the desired number of spaces that Chronicles should
use as indentation in the <code>textblocks</code> format.</p> <hr> <p>All of the discussed options are case-insensitive and accept a number of
truthy and falsy values such as <code>on</code>, <code>off</code>, <code>true</code>, <code>false</code>, <code>0</code>, <code>1</code>,
<code>yes</code>, <code>no</code> or <code>none</code>.</p> <h2 id="working-with-file-outputs"><a href="#working-with-file-outputs" class="header-anchor">#</a> Working with <code>file</code> outputs</h2> <p>When a stream has <code>file</code> outputs, you may choose to provide the log file
@ -266,10 +266,10 @@ to specify a gcsafe closure:</p> <div class="language-nim line-numbers-mode"><pr
<code>trace</code> statement. Normal logging can be considered a side effect, but <code>trace</code>
is meant as a debugging aid. It's analogous to Nim's <code>debugEcho</code>, which also
bypasses the effect system.</p> <h2 id="teaching-chronicles-about-your-types"><a href="#teaching-chronicles-about-your-types" class="header-anchor">#</a> Teaching Chronicles about your types</h2> <p>Chronicles can output log records in any of the formats supported by the Nim
<a href="https://github.com/status-im/nim-serialization" target="_blank" rel="noopener noreferrer"><code>serialization</code><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a> package.
<a href="https://github.com/status-im/nim-serialization" target="_blank" rel="noopener noreferrer"><code>serialization</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> package.
When you specify a named format such as <code>json</code>, Chronicles will expect that
your project also depends on the respective serialization package (e.g.
<a href="https://github.com/status-im/nim-json-serialization" target="_blank" rel="noopener noreferrer"><code>json_serialization</code><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a>).</p> <p>In the text formats (<code>textlines</code> and <code>textblocks</code>), the Nim's standard <code>$</code>
<a href="https://github.com/status-im/nim-json-serialization" target="_blank" rel="noopener noreferrer"><code>json_serialization</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>).</p> <p>In the text formats (<code>textlines</code> and <code>textblocks</code>), the Nim's standard <code>$</code>
operator will be used to convert the logged properties to strings.</p> <h3 id="formatit"><a href="#formatit" class="header-anchor">#</a> <code>formatIt</code></h3> <p>You can instruct Chronicles to alter this default behavior for a particular
type by providing a <code>chronicles.formatIt</code> override:</p> <div class="language-nim line-numbers-mode"><pre class="language-nim"><code><span class="token keyword">type</span> Dollar <span class="token operator">=</span> <span class="token keyword">distinct</span> int
chronicles<span class="token operator">.</span><span class="token function">formatIt</span><span class="token punctuation">(</span>Dollar<span class="token punctuation">)</span><span class="token operator">:</span> <span class="token string">&quot;$&quot;</span> <span class="token operator">&amp;</span> <span class="token operator">$</span><span class="token punctuation">(</span>it<span class="token operator">.</span>int<span class="token punctuation">)</span>
@ -347,10 +347,10 @@ publicLogScope<span class="token operator">:</span>
stream <span class="token operator">=</span> xmlout
info <span class="token string">&quot;New Video&quot;</span><span class="token punctuation">,</span> franchise <span class="token operator">=</span> <span class="token string">&quot;Tom &amp; Jerry&quot;</span><span class="token punctuation">,</span> episode <span class="token operator">=</span> <span class="token string">&quot;Smarty Cat&quot;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br></div></div><p>The produced output from the example will be:</p> <div class="language-xml line-numbers-mode"><pre class="language-xml"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>event</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>New Video<span class="token punctuation">&quot;</span></span> <span class="token attr-name">severity</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>INFO<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br></div></div><p>The produced output from the example will be:</p> <div class="language-xml line-numbers-mode"><pre class="language-xml"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>event</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>New Video<span class="token punctuation">&quot;</span></span> <span class="token attr-name">severity</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>INFO<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>tid</span><span class="token punctuation">&gt;</span></span>0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>tid</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>episode</span><span class="token punctuation">&gt;</span></span>Smarty Cat<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>episode</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>franchise</span><span class="token punctuation">&gt;</span></span>Tom <span class="token entity" title="&amp;">&amp;amp;</span> Jerry<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>franchise</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>franchise</span><span class="token punctuation">&gt;</span></span>Tom <span class="token entity named-entity" title="&amp;">&amp;amp;</span> Jerry<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>franchise</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>event</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p>As you can see, <code>customLogStream</code> looks similar to a regular <code>logStream</code>,
but it expects a log record type as its only argument.</p> <p>The record type is implemented by providing suitable definitons for
@ -373,13 +373,13 @@ scopes, Chronicles consumes a large amount of thread-local memory, roughly
proportional to the number of unique topic names and property names used
in the program.</p> <h2 id="future-directions"><a href="#future-directions" class="header-anchor">#</a> Future Directions</h2> <p>At the moment, Chronicles intentionally omits certain features expected
from a logging library such as log rotation and archival. We recommend
following the guidelines set in the <a href="https://12factor.net/logs" target="_blank" rel="noopener noreferrer">12-factor app methodology<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a>
following the guidelines set in the <a href="https://12factor.net/logs" target="_blank" rel="noopener noreferrer">12-factor app methodology<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>
and sending your log output to <code>stdout</code>. It should be the responsibility
of the supervising daemon of the app to implement log rotation and archival.</p> <p>We understand that certain users would want to take advantage of the
file sinks provided by Chronicles and these users may benefit from the
aforementioned features. If the Nim community provides a package for
a low-level abstraction of an automatically rotated and archived log
file, Chronicles will provide options for using it.</p></div> <footer class="page-edit"><!----> <!----></footer> <!----> </main></div><div class="global-ui"></div></div>
<script src="/assets/js/app.0bbcba5f.js" defer></script><script src="/assets/js/2.8e6705b7.js" defer></script><script src="/assets/js/7.11707fb6.js" defer></script>
<script src="/assets/js/app.b6b895fe.js" defer></script><script src="/assets/js/2.fd7e9e0b.js" defer></script><script src="/assets/js/9.249d32d4.js" defer></script>
</body>
</html>

View File

@ -4,12 +4,12 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Chronos | Nimbus Libraries</title>
<meta name="description" content="Ethereum 2.0 utilities and more">
<meta name="generator" content="VuePress 1.3.1">
<meta name="generator" content="VuePress 1.8.2">
<link rel="icon" href="/assets/img/logo.png">
<meta name="description" content="Ethereum 2.0 utilities and more">
<link rel="preload" href="/assets/css/0.styles.1d3235b8.css" as="style"><link rel="preload" href="/assets/js/app.0bbcba5f.js" as="script"><link rel="preload" href="/assets/js/2.8e6705b7.js" as="script"><link rel="preload" href="/assets/js/8.9a0afdb5.js" as="script"><link rel="prefetch" href="/assets/js/10.2c46fdf3.js"><link rel="prefetch" href="/assets/js/11.bbf981b9.js"><link rel="prefetch" href="/assets/js/12.af14dcd6.js"><link rel="prefetch" href="/assets/js/13.c624f59e.js"><link rel="prefetch" href="/assets/js/3.8d00273c.js"><link rel="prefetch" href="/assets/js/4.27329ebd.js"><link rel="prefetch" href="/assets/js/5.80ea750d.js"><link rel="prefetch" href="/assets/js/6.ccddad9d.js"><link rel="prefetch" href="/assets/js/7.11707fb6.js"><link rel="prefetch" href="/assets/js/9.40f78cab.js">
<link rel="stylesheet" href="/assets/css/0.styles.1d3235b8.css">
<link rel="preload" href="/assets/css/0.styles.74783a08.css" as="style"><link rel="preload" href="/assets/js/app.b6b895fe.js" as="script"><link rel="preload" href="/assets/js/2.fd7e9e0b.js" as="script"><link rel="preload" href="/assets/js/10.a7e5f96d.js" as="script"><link rel="prefetch" href="/assets/js/11.b620ddcc.js"><link rel="prefetch" href="/assets/js/12.cf1bd068.js"><link rel="prefetch" href="/assets/js/13.9dfac9d9.js"><link rel="prefetch" href="/assets/js/14.1ce3f7fe.js"><link rel="prefetch" href="/assets/js/3.c5869ccf.js"><link rel="prefetch" href="/assets/js/4.b9b777bd.js"><link rel="prefetch" href="/assets/js/5.073c37d9.js"><link rel="prefetch" href="/assets/js/6.7db49fe2.js"><link rel="prefetch" href="/assets/js/7.852d0869.js"><link rel="prefetch" href="/assets/js/8.b8ee59fd.js"><link rel="prefetch" href="/assets/js/9.249d32d4.js">
<link rel="stylesheet" href="/assets/css/0.styles.74783a08.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/assets/img/logo.png" alt="Nimbus Libraries" class="logo"> <span class="site-name can-hide">Nimbus Libraries</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/lib/nim-libp2p/" class="nav-link">
@ -18,7 +18,7 @@
Chronicles
</a></div><div class="nav-item"><a href="/lib/nimcrypto/" class="nav-link">
Nimcrypto
</a></div><div class="nav-item"><a href="/lib/nim-chronos/" class="nav-link router-link-exact-active router-link-active">
</a></div><div class="nav-item"><a href="/lib/nim-chronos/" aria-current="page" class="nav-link router-link-exact-active router-link-active">
Chronos
</a></div><div class="nav-item"><a href="/lib/nim-eth/" class="nav-link">
Eth
@ -30,14 +30,132 @@
Chronicles
</a></div><div class="nav-item"><a href="/lib/nimcrypto/" class="nav-link">
Nimcrypto
</a></div><div class="nav-item"><a href="/lib/nim-chronos/" class="nav-link router-link-exact-active router-link-active">
</a></div><div class="nav-item"><a href="/lib/nim-chronos/" aria-current="page" class="nav-link router-link-exact-active router-link-active">
Chronos
</a></div><div class="nav-item"><a href="/lib/nim-eth/" class="nav-link">
Eth
</a></div><div class="nav-item"><a href="/lib/nim-stew/" class="nav-link">
Stew
</a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>Chronos</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/lib/nim-chronos/#documentation" class="sidebar-link">Documentation</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/lib/nim-chronos/#installation" class="sidebar-link">Installation</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/lib/nim-chronos/#todo" class="sidebar-link">TODO</a><ul class="sidebar-sub-headers"></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="chronos"><a href="#chronos" class="header-anchor">#</a> Chronos</h1> <p>Chronos is an efficient library for asynchronous programming and an alternative to Nim's asyncdispatch.</p> <h2 id="documentation"><a href="#documentation" class="header-anchor">#</a> Documentation</h2> <p>You can find more documentation, notes and examples in <a href="https://github.com/status-im/nim-chronos/wiki" target="_blank" rel="noopener noreferrer">Wiki<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a>.</p> <h2 id="installation"><a href="#installation" class="header-anchor">#</a> Installation</h2> <p>You can use Nim official package manager <code>nimble</code> to install <code>chronos</code>. The most recent version of the library can be installed via:</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>$ nimble install https://github.com/status-im/nim-chronos.git
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="todo"><a href="#todo" class="header-anchor">#</a> TODO</h2> <ul><li>Pipe/Subprocess Transports.</li> <li>Multithreading Stream/Datagram servers</li> <li>Future[T] cancelation</li></ul></div> <footer class="page-edit"><!----> <!----></footer> <!----> </main></div><div class="global-ui"></div></div>
<script src="/assets/js/app.0bbcba5f.js" defer></script><script src="/assets/js/2.8e6705b7.js" defer></script><script src="/assets/js/8.9a0afdb5.js" defer></script>
</a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>Chronos</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/lib/nim-chronos/#installation" class="sidebar-link">Installation</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/lib/nim-chronos/#projects-using-chronos" class="sidebar-link">Projects using chronos</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/lib/nim-chronos/#documentation" class="sidebar-link">Documentation</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/lib/nim-chronos/#concepts" class="sidebar-link">Concepts</a></li><li class="sidebar-sub-header"><a href="/lib/nim-chronos/#dispatcher" class="sidebar-link">Dispatcher</a></li><li class="sidebar-sub-header"><a href="/lib/nim-chronos/#async-procedures-and-methods" class="sidebar-link">Async procedures and methods</a></li><li class="sidebar-sub-header"><a href="/lib/nim-chronos/#error-handling" class="sidebar-link">Error handling</a></li><li class="sidebar-sub-header"><a href="/lib/nim-chronos/#platform-independence" class="sidebar-link">Platform independence</a></li><li class="sidebar-sub-header"><a href="/lib/nim-chronos/#exception-effects" class="sidebar-link">Exception effects</a></li></ul></li><li><a href="/lib/nim-chronos/#todo" class="sidebar-link">TODO</a><ul class="sidebar-sub-headers"></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="chronos"><a href="#chronos" class="header-anchor">#</a> Chronos</h1> <p>Chronos is an efficient <a href="https://en.wikipedia.org/wiki/Async/await" target="_blank" rel="noopener noreferrer">async/await<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> framework for Nim. Features include:</p> <ul><li>Efficient dispatch pipeline for asynchronous execution</li> <li>HTTP server with SSL/TLS support out of the box (no OpenSSL needed)</li> <li>Cancellation support</li> <li>Synchronization primitivies like queues, events and locks</li> <li>FIFO processing order of dispatch queue</li> <li>Minimal exception effect support (see <a href="#exception-effects">exception effects</a>)</li></ul> <h2 id="installation"><a href="#installation" class="header-anchor">#</a> Installation</h2> <p>You can use Nim's official package manager Nimble to install Chronos:</p> <div class="language-text line-numbers-mode"><pre class="language-text"><code>nimble install https://github.com/status-im/nim-chronos.git
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>or add a dependency to your <code>.nimble</code> file:</p> <div class="language-text line-numbers-mode"><pre class="language-text"><code>requires &quot;chronos&quot;
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="projects-using-chronos"><a href="#projects-using-chronos" class="header-anchor">#</a> Projects using <code>chronos</code></h2> <ul><li><a href="https://github.com/status-im/nim-libp2p" target="_blank" rel="noopener noreferrer">libp2p<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> - Peer-to-Peer networking stack implemented in many languages</li> <li><a href="https://github.com/bung87/Looper" target="_blank" rel="noopener noreferrer">Looper<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> - Web framework</li> <li><a href="https://github.com/gogolxdong/2DeFi" target="_blank" rel="noopener noreferrer">2DeFi<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> - Decentralised file system</li></ul> <p><code>chronos</code> is available in the <a href="https://play.nim-lang.org/#ix=2TpS" target="_blank" rel="noopener noreferrer">Nim Playground<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p>Submit a PR to add yours!</p> <h2 id="documentation"><a href="#documentation" class="header-anchor">#</a> Documentation</h2> <h3 id="concepts"><a href="#concepts" class="header-anchor">#</a> Concepts</h3> <p>Chronos implements the async/await paradigm in a self-contained library, using
macros, with no specific helpers from the compiler.</p> <p>Our event loop is called a &quot;dispatcher&quot; and a single instance per thread is
created, as soon as one is needed.</p> <p>To trigger a dispatcher's processing step, we need to call <code>poll()</code> - either
directly or through a wrapper like <code>runForever()</code> or <code>waitFor()</code>. This step
handles any file descriptors, timers and callbacks that are ready to be
processed.</p> <p><code>Future</code> objects encapsulate the result of an async procedure, upon successful
completion, and a list of callbacks to be scheduled after any type of
completion - be that success, failure or cancellation.</p> <p>(These explicit callbacks are rarely used outside Chronos, being replaced by
implicit ones generated by async procedure execution and <code>await</code> chaining.)</p> <p>Async procedures (those using the <code>{.async.}</code> pragma) return <code>Future</code> objects.</p> <p>Inside an async procedure, you can <code>await</code> the future returned by another async
procedure. At this point, control will be handled to the event loop until that
future is completed.</p> <p>Future completion is tested with <code>Future.finished()</code> and is defined as success,
failure or cancellation. This means that a future is either pending or completed.</p> <p>To differentiate between completion states, we have <code>Future.failed()</code> and
<code>Future.cancelled()</code>.</p> <h3 id="dispatcher"><a href="#dispatcher" class="header-anchor">#</a> Dispatcher</h3> <p>You can run the &quot;dispatcher&quot; event loop forever, with <code>runForever()</code> which is defined as:</p> <div class="language-nim line-numbers-mode"><pre class="language-nim"><code><span class="token keyword">proc</span> <span class="token function">runForever<span class="token operator">*</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span>
<span class="token keyword">while</span> true<span class="token operator">:</span>
<span class="token function">poll</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>You can also run it until a certain future is completed, with <code>waitFor()</code> which
will also call <code>Future.read()</code> on it:</p> <div class="language-nim line-numbers-mode"><pre class="language-nim"><code><span class="token keyword">proc</span> <span class="token function">p</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">:</span> Future<span class="token punctuation">[</span>int<span class="token punctuation">]</span> <span class="token punctuation">{.</span>async<span class="token punctuation">.}</span> <span class="token operator">=</span>
await <span class="token function">sleepAsync</span><span class="token punctuation">(</span><span class="token number">100.</span>milliseconds<span class="token punctuation">)</span>
<span class="token keyword">return</span> <span class="token number">1</span>
echo waitFor <span class="token function">p</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment"># prints &quot;1&quot;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p><code>waitFor()</code> is defined like this:</p> <div class="language-nim line-numbers-mode"><pre class="language-nim"><code><span class="token keyword">proc</span> <span class="token function">waitFor*[T]</span><span class="token punctuation">(</span>fut<span class="token operator">:</span> Future<span class="token punctuation">[</span>T<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token operator">:</span> T <span class="token operator">=</span>
<span class="token keyword">while</span> <span class="token function">not</span><span class="token punctuation">(</span>fut<span class="token operator">.</span><span class="token function">finished</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token operator">:</span>
<span class="token function">poll</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token keyword">return</span> fut<span class="token operator">.</span><span class="token function">read</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><h3 id="async-procedures-and-methods"><a href="#async-procedures-and-methods" class="header-anchor">#</a> Async procedures and methods</h3> <p>The <code>{.async.}</code> pragma will transform a procedure (or a method) returning a
specialised <code>Future</code> type into a closure iterator. If there is no return type
specified, a <code>Future[void]</code> is returned.</p> <div class="language-nim line-numbers-mode"><pre class="language-nim"><code><span class="token keyword">proc</span> <span class="token function">p</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{.</span>async<span class="token punctuation">.}</span> <span class="token operator">=</span>
await <span class="token function">sleepAsync</span><span class="token punctuation">(</span><span class="token number">100.</span>milliseconds<span class="token punctuation">)</span>
echo <span class="token function">p</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">.</span><span class="token keyword">type</span> <span class="token comment"># prints &quot;Future[system.void]&quot;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>Whenever <code>await</code> is encountered inside an async procedure, control is passed
back to the dispatcher for as many steps as it's necessary for the awaited
future to complete successfully, fail or be cancelled. <code>await</code> calls the
equivalent of <code>Future.read()</code> on the completed future and returns the
encapsulated value.</p> <div class="language-nim line-numbers-mode"><pre class="language-nim"><code><span class="token keyword">proc</span> <span class="token function">p1</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{.</span>async<span class="token punctuation">.}</span> <span class="token operator">=</span>
await <span class="token function">sleepAsync</span><span class="token punctuation">(</span><span class="token number">1.</span>seconds<span class="token punctuation">)</span>
<span class="token keyword">proc</span> <span class="token function">p2</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{.</span>async<span class="token punctuation">.}</span> <span class="token operator">=</span>
await <span class="token function">sleepAsync</span><span class="token punctuation">(</span><span class="token number">1.</span>seconds<span class="token punctuation">)</span>
<span class="token keyword">proc</span> <span class="token function">p3</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{.</span>async<span class="token punctuation">.}</span> <span class="token operator">=</span>
<span class="token keyword">let</span>
fut1 <span class="token operator">=</span> <span class="token function">p1</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
fut2 <span class="token operator">=</span> <span class="token function">p2</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token comment"># Just by executing the async procs, both resulting futures entered the</span>
<span class="token comment"># dispatcher's queue and their &quot;clocks&quot; started ticking.</span>
await fut1
await fut2
<span class="token comment"># Only one second passed while awaiting them both, not two.</span>
waitFor <span class="token function">p3</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div><p>Don't let <code>await</code>'s behaviour of giving back control to the dispatcher surprise
you. If an async procedure modifies global state, and you can't predict when it
will start executing, the only way to avoid that state changing underneath your
feet, in a certain section, is to not use <code>await</code> in it.</p> <h3 id="error-handling"><a href="#error-handling" class="header-anchor">#</a> Error handling</h3> <p>Exceptions inheriting from <code>CatchableError</code> are caught by hidden <code>try</code> blocks
and placed in the <code>Future.error</code> field, changing the future's status to
<code>Failed</code>.</p> <p>When a future is awaited, that exception is re-raised, only to be caught again
by a hidden <code>try</code> block in the calling async procedure. That's how these
exceptions move up the async chain.</p> <p>A failed future's callbacks will still be scheduled, but it's not possible to
resume execution from the point an exception was raised.</p> <div class="language-nim line-numbers-mode"><pre class="language-nim"><code><span class="token keyword">proc</span> <span class="token function">p1</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{.</span>async<span class="token punctuation">.}</span> <span class="token operator">=</span>
await <span class="token function">sleepAsync</span><span class="token punctuation">(</span><span class="token number">1.</span>seconds<span class="token punctuation">)</span>
<span class="token keyword">raise</span> <span class="token function">newException</span><span class="token punctuation">(</span>ValueError<span class="token punctuation">,</span> <span class="token string">&quot;ValueError inherits from CatchableError&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">proc</span> <span class="token function">p2</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{.</span>async<span class="token punctuation">.}</span> <span class="token operator">=</span>
await <span class="token function">sleepAsync</span><span class="token punctuation">(</span><span class="token number">1.</span>seconds<span class="token punctuation">)</span>
<span class="token keyword">proc</span> <span class="token function">p3</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{.</span>async<span class="token punctuation">.}</span> <span class="token operator">=</span>
<span class="token keyword">let</span>
fut1 <span class="token operator">=</span> <span class="token function">p1</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
fut2 <span class="token operator">=</span> <span class="token function">p2</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
await fut1
echo <span class="token string">&quot;unreachable code here&quot;</span>
await fut2
<span class="token comment"># `waitFor()` would call `Future.read()` unconditionally, which would raise the</span>
<span class="token comment"># exception in `Future.error`.</span>
<span class="token keyword">let</span> fut3 <span class="token operator">=</span> <span class="token function">p3</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token keyword">while</span> <span class="token function">not</span><span class="token punctuation">(</span>fut3<span class="token operator">.</span><span class="token function">finished</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token operator">:</span>
<span class="token function">poll</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
echo <span class="token string">&quot;fut3.state = &quot;</span><span class="token punctuation">,</span> fut3<span class="token operator">.</span>state <span class="token comment"># &quot;Failed&quot;</span>
<span class="token keyword">if</span> fut3<span class="token operator">.</span><span class="token function">failed</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">:</span>
echo <span class="token string">&quot;p3() failed: &quot;</span><span class="token punctuation">,</span> fut3<span class="token operator">.</span>error<span class="token operator">.</span>name<span class="token punctuation">,</span> <span class="token string">&quot;: &quot;</span><span class="token punctuation">,</span> fut3<span class="token operator">.</span>error<span class="token operator">.</span>msg
<span class="token comment"># prints &quot;p3() failed: ValueError: ValueError inherits from CatchableError&quot;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br></div></div><p>You can put the <code>await</code> in a <code>try</code> block, to deal with that exception sooner:</p> <div class="language-nim line-numbers-mode"><pre class="language-nim"><code><span class="token keyword">proc</span> <span class="token function">p3</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{.</span>async<span class="token punctuation">.}</span> <span class="token operator">=</span>
<span class="token keyword">let</span>
fut1 <span class="token operator">=</span> <span class="token function">p1</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
fut2 <span class="token operator">=</span> <span class="token function">p2</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token keyword">try</span><span class="token operator">:</span>
await fut1
<span class="token keyword">except</span> CachableError<span class="token operator">:</span>
echo <span class="token string">&quot;p1() failed: &quot;</span><span class="token punctuation">,</span> fut1<span class="token operator">.</span>error<span class="token operator">.</span>name<span class="token punctuation">,</span> <span class="token string">&quot;: &quot;</span><span class="token punctuation">,</span> fut1<span class="token operator">.</span>error<span class="token operator">.</span>msg
echo <span class="token string">&quot;reachable code here&quot;</span>
await fut2
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>Chronos does not allow that future continuations and other callbacks raise
<code>CatchableError</code> - as such, calls to <code>poll</code> will never raise exceptions caused
originating from tasks on the dispatcher queue. It is however possible that
<code>Defect</code> that happen in tasks bubble up through <code>poll</code> as these are not caught
by the transformation.</p> <h3 id="platform-independence"><a href="#platform-independence" class="header-anchor">#</a> Platform independence</h3> <p>Several functions in <code>chronos</code> are backed by the operating system, such as
waiting for network events, creating files and sockets etc. The specific
exceptions that are raised by the OS is platform-dependent, thus such functions
are declared as raising <code>CatchableError</code> but will in general raise something
more specific. In particular, it's possible that some functions that are
annotated as raising <code>CatchableError</code> only raise on <em>some</em> platforms - in order
to work on all platforms, calling code must assume that they will raise even
when they don't seem to do so on one platform.</p> <h3 id="exception-effects"><a href="#exception-effects" class="header-anchor">#</a> Exception effects</h3> <p><code>chronos</code> currently offers minimal support for exception effects and <code>raises</code>
annotations. In general, during the <code>async</code> transformation, a generic
<code>except CatchableError</code> handler is added around the entire function being
transformed, in order to catch any exceptions and transfer them to the <code>Future</code>.
Because of this, the effect system thinks no exceptions are &quot;leaking&quot; because in
fact, exception <em>handling</em> is deferred to when the future is being read.</p> <p>Effectively, this means that while code can be compiled with
<code>{.push raises: [Defect]}</code>, the intended effect propagation and checking is
<strong>disabled</strong> for <code>async</code> functions.</p> <p>To enable checking exception effects in <code>async</code> code, enable strict mode with
<code>-d:chronosStrictException</code>.</p> <p>In the strict mode, <code>async</code> functions are checked such that they only raise
<code>CatchableError</code> and thus must make sure to explicitly specify exception
effects on forward declarations, callbacks and methods using
<code>{.raises: [CatchableError].}</code> (or more strict) annotations.</p> <h2 id="todo"><a href="#todo" class="header-anchor">#</a> TODO</h2> <ul><li>Pipe/Subprocess Transports.</li> <li>Multithreading Stream/Datagram servers</li></ul></div> <footer class="page-edit"><!----> <!----></footer> <!----> </main></div><div class="global-ui"></div></div>
<script src="/assets/js/app.b6b895fe.js" defer></script><script src="/assets/js/2.fd7e9e0b.js" defer></script><script src="/assets/js/10.a7e5f96d.js" defer></script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -4,12 +4,12 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Stew | Nimbus Libraries</title>
<meta name="description" content="Ethereum 2.0 utilities and more">
<meta name="generator" content="VuePress 1.3.1">
<meta name="generator" content="VuePress 1.8.2">
<link rel="icon" href="/assets/img/logo.png">
<meta name="description" content="Ethereum 2.0 utilities and more">
<link rel="preload" href="/assets/css/0.styles.1d3235b8.css" as="style"><link rel="preload" href="/assets/js/app.0bbcba5f.js" as="script"><link rel="preload" href="/assets/js/2.8e6705b7.js" as="script"><link rel="preload" href="/assets/js/11.bbf981b9.js" as="script"><link rel="prefetch" href="/assets/js/10.2c46fdf3.js"><link rel="prefetch" href="/assets/js/12.af14dcd6.js"><link rel="prefetch" href="/assets/js/13.c624f59e.js"><link rel="prefetch" href="/assets/js/3.8d00273c.js"><link rel="prefetch" href="/assets/js/4.27329ebd.js"><link rel="prefetch" href="/assets/js/5.80ea750d.js"><link rel="prefetch" href="/assets/js/6.ccddad9d.js"><link rel="prefetch" href="/assets/js/7.11707fb6.js"><link rel="prefetch" href="/assets/js/8.9a0afdb5.js"><link rel="prefetch" href="/assets/js/9.40f78cab.js">
<link rel="stylesheet" href="/assets/css/0.styles.1d3235b8.css">
<link rel="preload" href="/assets/css/0.styles.74783a08.css" as="style"><link rel="preload" href="/assets/js/app.b6b895fe.js" as="script"><link rel="preload" href="/assets/js/2.fd7e9e0b.js" as="script"><link rel="preload" href="/assets/js/13.9dfac9d9.js" as="script"><link rel="prefetch" href="/assets/js/10.a7e5f96d.js"><link rel="prefetch" href="/assets/js/11.b620ddcc.js"><link rel="prefetch" href="/assets/js/12.cf1bd068.js"><link rel="prefetch" href="/assets/js/14.1ce3f7fe.js"><link rel="prefetch" href="/assets/js/3.c5869ccf.js"><link rel="prefetch" href="/assets/js/4.b9b777bd.js"><link rel="prefetch" href="/assets/js/5.073c37d9.js"><link rel="prefetch" href="/assets/js/6.7db49fe2.js"><link rel="prefetch" href="/assets/js/7.852d0869.js"><link rel="prefetch" href="/assets/js/8.b8ee59fd.js"><link rel="prefetch" href="/assets/js/9.249d32d4.js">
<link rel="stylesheet" href="/assets/css/0.styles.74783a08.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/assets/img/logo.png" alt="Nimbus Libraries" class="logo"> <span class="site-name can-hide">Nimbus Libraries</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/lib/nim-libp2p/" class="nav-link">
@ -22,7 +22,7 @@
Chronos
</a></div><div class="nav-item"><a href="/lib/nim-eth/" class="nav-link">
Eth
</a></div><div class="nav-item"><a href="/lib/nim-stew/" class="nav-link router-link-exact-active router-link-active">
</a></div><div class="nav-item"><a href="/lib/nim-stew/" aria-current="page" class="nav-link router-link-exact-active router-link-active">
Stew
</a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/lib/nim-libp2p/" class="nav-link">
libp2p
@ -34,14 +34,14 @@
Chronos
</a></div><div class="nav-item"><a href="/lib/nim-eth/" class="nav-link">
Eth
</a></div><div class="nav-item"><a href="/lib/nim-stew/" class="nav-link router-link-exact-active router-link-active">
</a></div><div class="nav-item"><a href="/lib/nim-stew/" aria-current="page" class="nav-link router-link-exact-active router-link-active">
Stew
</a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>Stew</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/lib/nim-stew/#notable-libraries" class="sidebar-link">Notable libraries</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/lib/nim-stew/#layout" class="sidebar-link">Layout</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/lib/nim-stew/#compatibility" class="sidebar-link">Compatibility</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/lib/nim-stew/#using-stew-in-your-project" class="sidebar-link">Using stew in your project</a><ul class="sidebar-sub-headers"></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="stew"><a href="#stew" class="header-anchor">#</a> Stew</h1> <h1 id="stew-status-e-something-w-something"><a href="#stew-status-e-something-w-something" class="header-anchor">#</a> stew - status e-something w-something</h1> <p><a href="https://travis-ci.org/status-im/nim-stew" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/travis/status-im/nim-stew/master.svg?label=Linux%20/%20macOS" alt="Build Status (Travis)" title="Linux/macOS build status (Travis)"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a> <a href="https://ci.appveyor.com/project/nimbus/nim-stew" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/appveyor/ci/nimbus/nim-stew/master.svg?label=Windows" alt="Windows build status (Appveyor)" title="Windows build status (Appveyor)"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a> <a href="https://opensource.org/licenses/Apache-2.0" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License: Apache"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a> <a href="https://opensource.org/licenses/MIT" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a> <img src="https://img.shields.io/badge/stability-experimental-orange.svg" alt="Stability: experimental"></p> <p><code>stew</code> is collection of utilities, std library extensions and budding libraries
</a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>Stew</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/lib/nim-stew/#notable-libraries" class="sidebar-link">Notable libraries</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/lib/nim-stew/#layout" class="sidebar-link">Layout</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/lib/nim-stew/#compatibility" class="sidebar-link">Compatibility</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/lib/nim-stew/#using-stew-in-your-project" class="sidebar-link">Using stew in your project</a><ul class="sidebar-sub-headers"></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="stew"><a href="#stew" class="header-anchor">#</a> Stew</h1> <h1 id="stew-status-e-something-w-something"><a href="#stew-status-e-something-w-something" class="header-anchor">#</a> stew - status e-something w-something</h1> <p><a href="https://travis-ci.org/status-im/nim-stew" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/travis/status-im/nim-stew/master.svg?label=Linux%20/%20macOS" alt="Build Status (Travis)" title="Linux/macOS build status (Travis)"><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> <a href="https://ci.appveyor.com/project/nimbus/nim-stew" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/appveyor/ci/nimbus/nim-stew/master.svg?label=Windows" alt="Windows build status (Appveyor)" title="Windows build status (Appveyor)"><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> <a href="https://opensource.org/licenses/Apache-2.0" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License: Apache"><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> <a href="https://opensource.org/licenses/MIT" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT"><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> <img src="https://img.shields.io/badge/stability-experimental-orange.svg" alt="Stability: experimental"> <img src="https://github.com/status-im/nim-stew/workflows/nim-stew%20CI/badge.svg" alt="Github action"></p> <p><code>stew</code> is collection of utilities, std library extensions and budding libraries
that are frequently used at Status, but are too small to deserve their own
git repository.</p> <p>We also use <code>stew</code> as a staging ground for code that has yet to be
battle-tested.</p> <p>Some of these libraries may eventually be proposed for inclusion in Nim or
broken out into separate repositories.</p> <h2 id="notable-libraries"><a href="#notable-libraries" class="header-anchor">#</a> Notable libraries</h2> <p>Libraries are documented either in-module or on a separate README in their
respective folders</p> <ul><li><code>bitops2</code> - an updated version of <code>bitops.nim</code>, filling in gaps in original code</li> <li><code>byteutils</code> - utilities that make working with the Nim <code>byte</code> type convenient</li> <li><code>endians2</code> - utilities for converting to and from little / big endian integers</li> <li><code>ptrops</code> - pointer arithmetic utilities</li> <li><code>ranges</code> - utility functions for working with parts and blobs of memory</li> <li><code>shims</code> - backports of nim <code>devel</code> code to the stable version that Status is using</li></ul> <h2 id="layout"><a href="#layout" class="header-anchor">#</a> Layout</h2> <p><code>stew</code> modules are made to be fairly independent of each other, but generally
respective folders</p> <ul><li><code>arrayops</code> - small helpers and operations on <code>array</code>/<code>openArray</code></li> <li><code>assign2</code> - fast assignments (unlike the <code>=</code> operator in nim which is very slow)</li> <li><code>bitops2</code> - an updated version of <code>bitops.nim</code>, filling in gaps in original code</li> <li><code>byteutils</code> - utilities that make working with the Nim <code>byte</code> type convenient</li> <li><code>endians2</code> - utilities for converting to and from little / big endian integers</li> <li><code>objects</code> - get an object's base type at runtime, as a string</li> <li><code>ptrops</code> - pointer arithmetic utilities</li> <li><code>result</code> - friendly, exception-free value-or-error returns, similar to <code>Option[T]</code>, from <a href="https://github.com/arnetheduck/nim-result/" target="_blank" rel="noopener noreferrer">nim-result<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><code>shims</code> - backports of nim <code>devel</code> code to the stable version that Status is using</li> <li><code>sequtils2</code> - extensions to the <code>sequtils</code> module for working conveniently with <code>seq</code></li> <li><code>varints</code> - helpers for working with variable length integers</li></ul> <h2 id="layout"><a href="#layout" class="header-anchor">#</a> Layout</h2> <p><code>stew</code> modules are made to be fairly independent of each other, but generally
follow the following layout - if you've used C++'s <code>boost</code>, you'll feel right at
home:</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># Single-module libraries</span>
stew/small.nim <span class="token comment"># small libraries that fits in one module</span>
@ -75,6 +75,6 @@ submodule) or copy the file to your project instead.</p> <p>Typically, you will
submodules:</p> <div class="language-nim line-numbers-mode"><pre class="language-nim"><code><span class="token keyword">import</span> stew<span class="token operator">/</span>bitops2
<span class="token keyword">import</span> stew<span class="token operator">/</span>ranges<span class="token operator">/</span>bitranges
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>⚠️ No API/ABI stability - pick a commit and stick with it ⚠️</p></div> <footer class="page-edit"><!----> <!----></footer> <!----> </main></div><div class="global-ui"></div></div>
<script src="/assets/js/app.0bbcba5f.js" defer></script><script src="/assets/js/2.8e6705b7.js" defer></script><script src="/assets/js/11.bbf981b9.js" defer></script>
<script src="/assets/js/app.b6b895fe.js" defer></script><script src="/assets/js/2.fd7e9e0b.js" defer></script><script src="/assets/js/13.9dfac9d9.js" defer></script>
</body>
</html>

File diff suppressed because one or more lines are too long