<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Arman Riazi on Medium]]></title>
        <description><![CDATA[Stories by Arman Riazi on Medium]]></description>
        <link>https://medium.com/@armanriazi-github-io?source=rss-becac8404bb8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*-lZb70CZMVGJdSKJj77kaA.jpeg</url>
            <title>Stories by Arman Riazi on Medium</title>
            <link>https://medium.com/@armanriazi-github-io?source=rss-becac8404bb8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 05:56:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@armanriazi-github-io/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[آرمانوسرویس]]></title>
            <link>https://armanriazi-github-io.medium.com/%D8%A2%D8%B1%D9%85%D8%A7%D9%86%D9%88%D8%B3%D8%B1%D9%88%DB%8C%D8%B3-4852a938a977?source=rss-becac8404bb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/4852a938a977</guid>
            <dc:creator><![CDATA[Arman Riazi]]></dc:creator>
            <pubDate>Fri, 21 Nov 2025 20:55:22 GMT</pubDate>
            <atom:updated>2025-11-21T20:56:36.784Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zatxRamaByoY9GfUA8Lk8Q.jpeg" /></figure><h3>خلاصه خدمات</h3><p>خدمات #برق_خودرو — #آپشن‌ها</p><p>#موتور_شارژی و #اسکوتر</p><p>#الکترونیک</p><p>خدمات #سرویس_دوره‌_ای_خودرو و #تنظیم_موتور</p><p>#برق_ساختمان (پس از ساخت)</p><p>#فناوری_اطلاعات و #برنامه‌نویسی</p><h3>محصولات</h3><p>- اولین اپلیکیشن آموزش #برق_خودرو</p><p>در سریعترین زمان ممکن</p><p>#ایرانی و #خارجی</p><p>قابل دانلود بطور #رایگان</p><p>#اوتوآرمانو AutoArmano</p><p>- نماینده رسمی فروش #دیاگ_شخصی و #تعمیرگاهی #موبیکار</p><p>در #اصفهان و سایر شهرستان‌ها.</p><p>ساخته شده به دست توانمند فارغ التحصیلان #دانشگاه_شریف</p><p>- کتاب برنامه نویسی #Rust به عنوان یک #زبان_مادر_مدرن — -</p><p>- کلیه #محتواهای_تولیدی نظیر #فیلم و #تصاویر در #کانال_یوتیوب قرار داده شده است و سایر #رسانه‌های_اجتماعی (با همین نام)، لینک‌هایی به #یوتیوب دارند.</p><p>- <strong>یادآوری</strong>: پس حتما #یوتیوب subscribe شود تا به جمع #فارسی_زبانان مقیم و غیرمقیم بپیوندید.</p><p>می‌توانید در معرفی #ایده‌ها، #محصولات و #خدمات خود با ما سهیم باشید.</p><blockquote><em>تنها کافیست تا از طریق #واتساپ با ما در ارتباط باشید. 09338032263</em></blockquote><p>آدرس در فایل اسکن شده #QR_Code بروز شده است.</p><p><strong>با سپاس</strong></p><p>— -</p><p>### هشتگ‌های مرتبط بیشتر:</p><p>#اپلیکیشن_آموزشی #یادگیری_آنلاین #آموزش_فنی #هوشمندسازی #پشتیبانی #سرویس_خودرو #خدمات_اتومبیل #کتاب_برنامه_نویسی #آموزش_مجازی #آرمانو #تعمیرات_خودرو</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4852a938a977" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rust as a Modern Mother Language Advanced Techniques for Developing Robust Applications]]></title>
            <link>https://armanriazi-github-io.medium.com/rust-as-a-modern-mother-language-advanced-techniques-for-developing-robust-applications-41cab69dd9ea?source=rss-becac8404bb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/41cab69dd9ea</guid>
            <category><![CDATA[rust-programming-language]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[webassembly]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[ai-development]]></category>
            <dc:creator><![CDATA[Arman Riazi]]></dc:creator>
            <pubDate>Wed, 27 Nov 2024 08:53:22 GMT</pubDate>
            <atom:updated>2024-11-30T16:53:46.531Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*RuVnDlEZUhWsERx-oK8EpQ.png" /></figure><p>“The book comprises the best practices of Rust programming. I wrote and published it between 2022 and 2024, and it is presented in two volumes on A4-sized paper.</p><p>The question arises: What is the relationship between ‘Rust for System Programming’ and this book?</p><p>The ‘Rust for System Programming’ book published by OrangeAva serves as only one of the references for my work; it is not a translation of the book. I served as the technical reviewer for ”Rust for System Programming.” While I had initially hoped to incorporate more content from this book, I found that I could only utilize a few pages from the first chapter. This was primarily because I had already gathered sufficient material for my own book prior to reviewing that one.</p><p>I am the author of this comprehensive book, which contains over 30 diverse references.”</p><blockquote>Book Description</blockquote><p>The book “RUST as a Modern Mother Language” contains advanced techniques for Rust programming aimed at developing robust applications. This comprehensive guide addresses advanced error and memory management techniques, as well as parallel and concurrent processing in Rust. It seeks to provide readers with an effective pathway for learning and utilizing Rust by integrating principles of object-oriented design with performance optimization concepts.</p><p>In April 2021, Google, which supports the development of Android using Rust, initiated efforts to incorporate the Rust language into the Linux kernel. According to a report from The New Stack, Linus Torvalds noted that some attempts to integrate new languages into the Linux kernel have not been successful: “We tried C++ 25 years ago. We experimented for two weeks and then abandoned the effort.” The book delves into advanced techniques for error and memory management, parallel and concurrent processing in Rust, while aiming to combine object-oriented design and performance optimization concepts to create an effective learning and application pathway for readers. This book is divided into two volumes; the first volume covers introductory topics, language syntax, advanced memory management, unsafe code writing, pointers anatomy, and behavior patterns. The second volume focuses specifically on advanced object-oriented and functional programming topics, debugging, code correctness, concurrent programming, and introduces other recent studies in Rust programming. Additionally, the second section of the second volume offers project-based solutions for the exercises from both volumes for our esteemed readers.</p><p>“One of the common questions is: if we are familiar with a programming language and utilize online resources for learning, why should we use this book to learn Rust?</p><p>It should be noted that learning Rust differs from other languages, and half of the learning curve involves understanding conceptual frameworks; thus, this language extends beyond simple command instruction. The author’s aim is to establish an effective connection between concepts and practical application, thereby facilitating the learning process for our valued readers.”</p><blockquote><strong>English version</strong></blockquote><p>Markedown book: <a href="https://github.com/armanriazi/rust-all-in-one">Rust-All-In-One</a></p><blockquote><strong>Persian versions</strong></blockquote><p><strong>Physical:</strong></p><p><em>Published by Motekhassesan(</em><a href="https://www.motekhassesan.com/?p=48543"><em>Vol.1</em></a><em>) , (</em><a href="https://www.motekhassesan.com/?p=48977"><em>Vol.2</em></a><em>)</em></p><p><em>Digikala (</em><a href="https://www.digikala.com/product/dkp-17163983/%DA%A9%D8%AA%D8%A7%D8%A8-%D8%AA%DA%A9%D9%86%DB%8C%DA%A9%D9%87%D8%A7%DB%8C-%D9%BE%DB%8C%D8%B4%D8%B1%D9%81%D8%AA%D9%87-%D8%A8%D8%B1%D9%86%D8%A7%D9%85%D9%87-%D9%86%D9%88%DB%8C%D8%B3%DB%8C-rust-%D8%A8%D8%B1%D8%A7%DB%8C-%D8%AA%D9%88%D8%B3%D8%B9%D9%87-%D8%A8%D8%B1%D9%86%D8%A7%D9%85%D9%87%D9%87%D8%A7%DB%8C-%DA%A9%D8%A7%D8%B1%D8%A8%D8%B1%D8%AF%DB%8C-%D9%82%D9%88%DB%8C-%D8%A7%D8%AB%D8%B1-%D8%A2%D8%B1%D9%85%D8%A7%D9%86-%D8%B1%DB%8C%D8%A7%D8%B6%DB%8C-%D9%86%D8%B4%D8%B1-%D9%85%D8%AA%D8%AE%D8%B5%D8%B5%D8%A7%D9%86/"><em>Vol.1</em></a><em>) (</em><a href="https://www.digikala.com/product/dkp-17195288/%DA%A9%D8%AA%D8%A7%D8%A8-rust-%D8%A8%D9%87-%D8%B9%D9%86%D9%88%D8%A7%D9%86-%DB%8C%DA%A9-%D8%B2%D8%A8%D8%A7%D9%86-%D9%85%D8%A7%D8%AF%D8%B1-%D9%85%D8%AF%D8%B1%D9%86-%D8%AA%DA%A9%D9%86%DB%8C%DA%A9%D9%87%D8%A7%DB%8C-%D9%BE%DB%8C%D8%B4%D8%B1%D9%81%D8%AA%D9%87-%D8%A8%D8%B1%D9%86%D8%A7%D9%85%D9%87-%D9%86%D9%88%DB%8C%D8%B3%DB%8C-rust-%D8%A8%D8%B1%D8%A7%DB%8C-%D8%AA%D9%88%D8%B3%D8%B9%D9%87-%D8%A8%D8%B1%D9%86%D8%A7%D9%85%D9%87-%D9%87%D8%A7%DB%8C-%DA%A9%D8%A7%D8%B1%D8%A8%D8%B1%D8%AF%DB%8C-%D9%82%D9%88%DB%8C-%D8%A7%D8%AB%D8%B1-%D8%A2%D8%B1%D9%85%D8%A7%D9%86-%D8%B1%DB%8C%D8%A7%D8%B6%DB%8C-%D9%86%D8%B4%D8%B1-%D9%85%D8%AA%D8%AE%D8%B5%D8%B5%D8%A7%D9%86-%D8%AC%D9%84%D8%AF-%D8%AF%D9%88%D9%85/"><em>Vol.2</em></a><em>)</em></p><p><strong>E-Book:</strong></p><p><em>Taghcheh (Vol.1) (Vol.2)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41cab69dd9ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ultimate Rust for Systems Programming: Master Core Programming for Architecting Secure and Reliable…]]></title>
            <link>https://armanriazi-github-io.medium.com/ultimate-rust-for-systems-programming-master-core-programming-for-architecting-secure-and-reliable-04479701bdba?source=rss-becac8404bb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/04479701bdba</guid>
            <category><![CDATA[ai-development]]></category>
            <category><![CDATA[webassembly]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[rust-programming-language]]></category>
            <dc:creator><![CDATA[Arman Riazi]]></dc:creator>
            <pubDate>Wed, 01 May 2024 06:42:34 GMT</pubDate>
            <atom:updated>2024-05-01T06:42:34.335Z</atom:updated>
            <content:encoded><![CDATA[<h3>Ultimate Rust for Systems Programming: Master Core Programming for Architecting Secure and Reliable Software Systems with Rust and WebAssembly</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QlvSpIVu9Watz2mBCm9jPg.png" /><figcaption><a href="https://www.amazon.co.uk/Ultimate-Rust-Systems-Programming-Architecting/dp/8196994737">Amazon Link</a></figcaption></figure><blockquote><strong>Book Description</strong></blockquote><p>This book is your guide to mastering Rust programming, equipping you with essential skills and insights for efficient system programming. It starts by introducing Rust’s significance in the system programming domain and highlighting its advantages over traditional languages like C/C++. You’ll then embark on a practical journey, setting up Rust on various platforms and configuring the development environment. From writing your first “Hello, World!” program to harness the power of Rust’s package manager, Cargo, the book ensures a smooth initiation into the language.</p><p>Delving deeper, the book covers foundational concepts, including variables, data types, control flow, functions, closures, and crucial memory management aspects like ownership, borrowing, and lifetimes. Special attention is given to Rust’s strict memory safety guarantees, guiding you in writing secure code with the assistance of the borrow checker.</p><p>The book extends its reach to Rust collections, error-handling techniques, and the complexities of concurrency management. From threads and synchronization primitives like Mutex and RwLock to asynchronous programming with async/await and the Tokio library, you’ll gain a comprehensive understanding of Rust’s capabilities. This book covers it all</p><h4>Table of Contents</h4><blockquote>1. Systems #Programming with Rust<br>2. Basics of Rust<br>3. Traits and Generics<br>4. Rust Built-In Data Structures<br>5. #Error Handling and Recovery<br>6. #Memory Management and Pointers<br>7. Managing #Concurrency<br>8. Command Line Programs<br>9. Working with Devices I/O in Rust<br>10. Iterators and Closures<br>11. #Unit Testing in Rust<br>12. Network Programming<br>13. Unsafe Coding in Rust<br>14. #Asynchronous Programming<br>15. #Web_Assembly with #Rust</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oRaYytoRWKv2PpwUW_RHgg.png" /><figcaption>Technical Reviewer</figcaption></figure><p><a href="https://orangeava.com/products/ultimate-rust-for-systems-programming"><em>Published by OrangeAva</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=04479701bdba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Digital Transformation in Smart Cities Decentralized Architecture for Sustainable Development…]]></title>
            <link>https://armanriazi-github-io.medium.com/digital-transformation-in-smart-cities-decentralized-architecture-for-sustainable-development-e16285536eab?source=rss-becac8404bb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/e16285536eab</guid>
            <category><![CDATA[smart-city-solutions]]></category>
            <category><![CDATA[regenerative-finance]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Arman Riazi]]></dc:creator>
            <pubDate>Wed, 01 May 2024 06:32:33 GMT</pubDate>
            <atom:updated>2024-11-27T08:31:51.208Z</atom:updated>
            <content:encoded><![CDATA[<h3>Digital Transformation in Smart Cities Decentralized Architecture for Sustainable Development within the Web 3.0 Ecosystem</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*T4om_poApGdttPW19zAzWw.png" /><figcaption><a href="https://doi.org/10.5281/zenodo.11002930">Link</a></figcaption></figure><p><strong>Abstract</strong></p><p>In the burgeoning landscape of smart city infrastructure, the proliferation of Web 3.0 systems introduces distinct challenges, particularly concerning data security and scalability. The evolution of Industry 4.0 and Society 5.0 marks a significant progression in urban system capabilities. Central to this progression is the harmonious fusion of Information and Communication Technology (ICT) with the latest technological innovations, covering the broad spectrum of production and enterprise activities. This fusion is pivotal in stimulating an active flow of information, cultivating trust, improving operational efficiency, and elevating profitability for a wide array of stakeholders. This study investigates the congruence between the ReFi (Regenerative Finance) concept, which is founded on eight essential principles, and the principles underlying Smart City initiatives, both of which advocate for sustainable urban progression. The ReFi concept’s principles are also integral to the Smart City framework. The anticipated scenario includes the formulation of smart contracts and their implementation on a blockchain network, which will manage access roles in IoT data sensing. The research’s objective is to survey and suggest a framework and key considerations for the design and execution of the Web 3.0 ecosystem. This ecosystem represents the amalgamation of progress in the Internet-of-Things (IoT), Artificial Intelligence (AI), ReFi, Decentralized Finance (DeFi), and smart cities. The study emphasizes the revolutionary capacity of Web 3.0 to drive cities into a future that is not only more intelligent but also more robust, flexible, and responsive to the ever-changing demands of society.</p><p>Keywords: #Natural capitalism, #Sustainability, #Smart city, #Web 3.0</p><p><strong>Introduction</strong></p><p>Natural capitalism adopts the stance that there is nothing fundamentally flawed about the existing system and that whatever flaws do exist will have technical fixes — as in smart city solutions for perceived urban problems. This assumption does not factor in that market economics have no moral compass, as promoted in Milton Friedman’s dictum “Greed is Good.”<br>The amoral imperative that the ownership of the entire planet remains, and should continue to remain in private hands “a monistic distortion (by which everything is considered capital is introduced and the reciprocal independence among factors of production as sources of value is eliminated” [7].<br>What is Society 5.0. In particular, the focus is on the following key concepts which are parallel aspects of the society: “a human-centered society,” “merging cyberspace with physical space,” “a knowledge-intensive society,” and “a data-driven society.” Understanding these four concepts enables us to develop the approach required to make Society 5.0 a reality [5].<br>Understanding economies as a network of interdependent agents bound in a common cause of social, environmental, and economic well-being. This change in thinking implies embracing circular value-chains, which primarily focus on lasting constructive practice rather than on short-term monitory gains. From ‘how much money’ to ‘where the money goes’ to create lasting holistically, beneficial impacts can thus become the new mantra [5].</p><p>Development of new strategies for favoring the transition to smart cities, integrating existing urban plans and redefine them in a common and unique sustainable urban plan (mobility, energy, ICT…), that would implement a holistic strategy with the objective to transform the<br>city and to make it smarter [10].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*mOM2Y_kyO2UYXs4efN3Ijg.png" /><figcaption>21Smartcity Framework</figcaption></figure><h3><strong>Funding sources</strong></h3><p>This article was not financed by any internal or external agent.<br>Declaration of competing interest<br>None.</p><h3><strong>Acknowledgments</strong></h3><p>The research is not a part of any funded research grant or financially supported by any external organization.</p><h3><strong>References</strong></h3><p>[1]: Sorensen, D.(2023). Tokenized Carbon Credits. Ledger, 8. doi.org/10.5195/ledger.2023.294</p><p>[2]: Riazi, A. (2024). Understanding the landscape of regenerating finance and digital transformation.<br>Zenodo. doi.org/10.5281/ZENODO.10512397. ScieNFT. scienft.com/nfts/318</p><p>[3]: Riazi, A. (2023d). Using ACO Algorithm to Improve Performance for Container-based Scientificworkflows. Zenodo. doi.org/10.5281/ZENODO.8105650. ScieNFT. scienft.com/nfts/155</p><p>[4]: (N.d.-b). Org.au. Retrieved April 10, 2024, from apo.org.au/node/321467</p><p>[5]: Hitachi-UTokyo Laboratory(H-UTokyo Lab.) (Ed.). (2020). Society 5.0: A people-centric super-smart society. Springer Singapore.</p><p>[6]: Jiang, H., Jiang, P., Wang, D., &amp; Wu, J. (2021). Can smart city construction facilitate green total factor productivity? A quasi-natural experiment based on China’s pilot smart city. Sustainable Cities<br>and Society, 69(102809), 102809. doi.org/10.1016/j.scs.2021.102809</p><p>[7]: Suartika, G. A. M., &amp; Cuthbert, A. (2020). The sustainable imperative — smart cities, technology and development. Sustainability, 12(21), 8892. doi.org/10.3390/su12218892</p><p>[8]: Biloria, N. (2021). From smart to empathic cities. Frontiers of Architectural Research, 10(1), 3–16. doi.org/10.1016/j.foar.2020.10.001</p><p>[9]: Oh, J. (2020). Smart city as a tool of citizen-oriented urban regeneration: Framework of preliminary evaluation and its application. Sustainability, 12(17), 6874. doi.org/10.3390/su12176874</p><p>[10]:(N.d.). Researchgate.net. Retrieved April 10, 2024, from <a href="http://www.researchgate.net/profile/Miguel-">www.researchgate.net/profile/Miguel-</a><br>Garcia-Fuentes/publication/313790319_Towards_smarter_and_more_sustainable_cities_The_remourban_model/links/58da30c0aca272d801d50da8/Towards-smarter-and-more-sustainable-cities-The-remourban-model.pdf</p><p>[11]: A.N. (2023, November 10). Blockchain-based tokenization for decentralized issuance and exchange of carbon offsets. Zanders. zandersgroup.com/en/insights/blog/blockchain-based-<br>tokenisation-for-decentralised-issuance-and-exchange-of-carbon-offsets</p><p>[12]: Dey, S., Saha, S., Singh, A. K., &amp; McDonald-Maier, K. (2022a). SmartNoshWaste: Using blockchain, machine learning, cloud computing and QR code to reduce food waste in decentralized<br>Web 3.0 enabled smart cities. Smart Cities, 5(1), 162–176. doi.org/10.3390/smartcities5010011</p><p>[13]: Guenduez, A. A., Mergel, I., Schedler, K., Fuchs, S., &amp; Douillet, C. (2024). Institutional work in smart cities: Interviews with smart city managers. Urban Governance.doi.org/10.1016/j.ugj.2024.01.003</p><p>[14]: (N.d.). Iop.org. Retrieved April 12, 2024, from iopscience.iop.org/article/10.1088/1757-899X/1107/1/012228/meta</p><p>[15]: Razzaq, A., Altamimi, A. B., Alreshidi, A., Ghayyur, S. A. K., Khan, W., &amp; Alsaffar, M. (2023).IoT data sharing platform in web 3.0 using blockchain technology. Electronics, 12(5), 1233.doi.org/10.3390/electronics12051233</p><p>[16]: Praful Bharadiya, J. (2023). Artificial intelligence and the future of web 3.0: Opportunities and challenges ahead. American Journal of Computer Science and Technology. doi.org/10.11648/j.ajcst.20230602.14</p><p>[17]: Li, X., Wang, Z., Leung, V. C. M., Ji, H., Liu, Y., &amp; Zhang, H. (2022). Blockchain- empowered data-driven networks: A survey and outlook. ACM Computing Surveys, 54(3), 1–38. doi.org/kcn9</p><p>[18]: van Pelt, R., Jansen, S., Baars, D., &amp; Overbeek, S. (2021). Defining blockchain governance: A framework for analysis and comparison. Information Systems Management, 38(1), 21–41. doi.org/gm2m6b</p><p>[19]: Weyl, E. G., Ohlhaver, P., &amp; Buterin, V. (2022). Decentralized society: Finding Web3’s soul. SSRN Electronic Journal. doi.org/10.2139/ssrn.4105763</p><p><a href="https://www.academia.edu/117794720/Digital_Transformation_in_Smart_Cities_Decentralized_Architecture_for_Sustainable_Development_within_the_Web_3_0_Ecosystem"><em>To gain full access to the paper</em></a></p><p><a href="https://scienft.com/nfts/5756"><em>NFT address of the paper</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e16285536eab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Free of charge: Hexagonal Architecture(Domain-Driven-Design) for you]]></title>
            <link>https://armanriazi-github-io.medium.com/free-of-charge-hexagonal-architecture-domain-driven-design-for-you-4c2a1814ca59?source=rss-becac8404bb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c2a1814ca59</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[hexagonal-architecture]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[domain-driven-design]]></category>
            <dc:creator><![CDATA[Arman Riazi]]></dc:creator>
            <pubDate>Mon, 15 Jan 2024 22:42:42 GMT</pubDate>
            <atom:updated>2024-01-15T22:45:12.945Z</atom:updated>
            <content:encoded><![CDATA[<h3>Free of charge: Hexagonal Architecture(DDD) for you</h3><p><strong>Kindly Note:</strong></p><p>No cost will be charged for the design of your system. For the first time, it is completely free!<br>As the manager or founder of a company, you may want to upgrade your organization’s processes and require an engineered plan for developing a new domain or even reverse engineering!<br>No doubt, every case of modeling will be work by DDD. Called “system”! so you don’t need to be concern that your business won’t fit with software engineer solutions.<br>Also, if you have an idea and operate as a registered start-up company, you may need analysis and software engineering at the beginning. Creating a design would be significant to complete your idea. Here is where Arman Riazi is at your service.</p><p>Beyond the Model Driven Design (MDD) methodology, the Object Management Group (OMG) created a conceptual framework called Model Driven Architecture (MDA).</p><ol><li>Computation Independent Model (CIM): This model focuses on the domain model.</li><li>Platform Independent Model (PIM): This model focuses on a general platform, where a solution is<br>deployed.</li><li>Platform Specific Model (PSM): This model focuses on a specific platform, where a solution is deployed.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*9C3DjC8It_0si_wGHaVq3A.png" /><figcaption>Figure 1. Hexagonal architecture</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*pwGLrmiqHIuIeDTCe6d_rg.png" /><figcaption>Figure 2. Hexagonal architecture</figcaption></figure><p><strong>Why is it good to invest in hexagonal architecture?</strong><br>The first reason to invest in hexagonal architecture comes from a cost-benefit argument. Not only is it beneficial from a technical perspective, but also from a business point of view. One of the primary goals of an architect is to minimize the cost of the creation and maintenance of software and, simultaneously, maximize the architecture’s benefits to the business.<br>The main benefit of hexagonal architecture for the organization is in the form of money. Companies invest a lot of capital every month in software maintenance, which can encompass refactoring or even rebuilding an<br>application. Hexagonal architecture reduces the cost of maintenance by separating different parts of the application. This clear separation of responsibilities and layers allows us to evolve or change functionalities more easily.<br>For example, when we want to change from REST to gRPC, we only need to focus our efforts on the transport layer while the rest of the code can remain intact. Hexagonal architecture is based on a few principles that should be followed to build well-structured components. If we overlook any of them, we will experience problems in the future. Additionally, it can be quite tortuous to change bad implementations, especially in a system that runs on production.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*8ie3BwjVo2Wz3VTPFBZi2w.png" /><figcaption>Figure 3. Well-defined boundaries</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CxHq-dxt-qf_0lD_KJk3vA.png" /><figcaption>Figure 4. Class Digram</figcaption></figure><p><a href="https://armanriazi.github.io/services/"><strong><em>Keep in touch with me.</em></strong></a><br>(After reviewing your form I’d be happy to select your works among the other candidates)</p><p><a href="https://drive.google.com/file/d/1ZFMDr7QjKBG62FKQH5B6kCTwuY3mQcSK/view?usp=sharing"><em>To gain access to the full version of pdf</em></a></p><p><a href="https://armanriazi.github.io/forms/ddd/"><em>Please fill out the form</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c2a1814ca59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Mind Mapping of Substrate framework]]></title>
            <link>https://medium.com/coinmonks/a-mind-mapping-of-substrate-framework-aa06ed0f8cc4?source=rss-becac8404bb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa06ed0f8cc4</guid>
            <category><![CDATA[rust-programming-language]]></category>
            <category><![CDATA[blockchain-accelerator]]></category>
            <category><![CDATA[polkadot]]></category>
            <category><![CDATA[blockchain-investment]]></category>
            <category><![CDATA[substrate-blockchain]]></category>
            <dc:creator><![CDATA[Arman Riazi]]></dc:creator>
            <pubDate>Mon, 15 Jan 2024 22:14:57 GMT</pubDate>
            <atom:updated>2024-01-22T16:28:11.850Z</atom:updated>
            <content:encoded><![CDATA[<p>Parity Substrate framework( Written by Rust Programming)</p><h4><strong>What is the Substrate framework?</strong></h4><p>Substrate-based chains are designed to seamlessly connect to Polkadot, granting access to its system of parallel transactions, cross-chain transfers, and an expanding support network.</p><p>Substrate makes building a blockchain far easier, faster, cheaper, and safer than ever before. As an open-source framework, developers gain free access to a wide codebase developed and used by industry-leading teams building some of the biggest networks today. Learn more.</p><h3>More than 150 projects are building on Substrate</h3><p>From DeFi to NFTs, gaming to decentralized indentity, and more, Substrate’s technology is fueling the next wave of innovation in the blockchain industry. Learn more about how the ecosystem of builders have addressed prominent challenges such as transaction costs, network security, and more.</p><p><strong>Parity Technologies</strong> is the software development company behind some of the world’s most trusted Web3 technology. It was founded in 2015 and succeeded in building some of the fastest and most secure open-source software for the decentralized web, including clients for Ethereum, Bitcoin, and Zcash. Parity has now moved on from these to address the previous limitations of blockchain technology, creating Substrate and developing the ground-breaking Kusama and Polkadot networks.</p><p><a href="https://armanriazi.github.io/public/blockchain/Substrate/"><em>Running Substrate Nodes and Development some pallet and smart contract with ink! framework which written by Rust.</em></a></p><p><strong>Kindely Note:</strong></p><p>If you want to get updated-mind-mapping image, send me an Email to <a href="/service/mailto:armanriazi.github.io@gmail.com">armanriazi.github.io@gmail.com</a></p><p>(Title: armanriazi.github.io_Substrate_MindMapping)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ObLUpcuy_cFFnVDLxuQw6g.png" /><figcaption>Parity: Substrate framework</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa06ed0f8cc4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/a-mind-mapping-of-substrate-framework-aa06ed0f8cc4">A Mind Mapping of Substrate framework</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Towards a Blanket Licensing Digitized of Music NFT Decentralized]]></title>
            <link>https://armanriazi-github-io.medium.com/towards-a-blanket-licensing-digitized-of-music-nft-decentralized-6329477d8f07?source=rss-becac8404bb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/6329477d8f07</guid>
            <dc:creator><![CDATA[Arman Riazi]]></dc:creator>
            <pubDate>Mon, 15 Jan 2024 22:01:03 GMT</pubDate>
            <atom:updated>2024-01-15T22:02:40.269Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/251/1*BAsNVlDuKJVQuy4-cwvPPQ.png" /><figcaption><a href="https://zenodo.org/badge/DOI/10.5281/zenodo.8023208.svg">DOI/10.5281/zenodo.8023208.svg</a></figcaption></figure><p><strong>Abstract</strong></p><p>Nowadays, as a result of technological advances, the number of users who use podcasts and streaming music services is increasing. There are protection and promotion standards, whether you are a singer, artist, record label, composer, investor or simply interested in the blockchain space. A solution that helps people claim, publish and monetize music works while providing transparency and insights into song rights, performance and revenues. The “21MFS” application suite consists of various solutions tailored to specific requirements.</p><p>Artificial intelligence in the music industry is a threat rather than a benefit. For example, virtual vocal synthesizers that make a singer’s voice sound like that of a famous artist. Who knows? Maybe a tool called MusicGPT will soon be available! Currently, the only way to cope with AI threats is to create laws and democracy using technologies that are resistant to artificial intelligence such as blockchain. The proposed approach follows an engineering path towards non-fungible assets to earn attractive incomes. Requirement to a solution that allows users to share music with others and promotes the feeling of exclusivity. The proposed approach follows an engineering path to non-fungible assets to achieve attractive revenues. Solutions also allow users to distribute music to cutting-edge new platforms. You can enter the “Web3.0” era, discover groundbreaking fan engagement strategies, and rapidly produce NFT collections from your publication catalogue to access new revenue streams.</p><p>Keywords: #NFT #Music #Audio #Metaverse #Musical sophistication #Active engagement</p><ol><li><strong>Introduction</strong><br>Blockchain, which is a technology for building distributed ledgers that provide an immutable log of transactions recorded in a distributed network, has become prominent recently as the underlying technology of cryptocurrencies and is revolutionizing data storage and processing in computer network systems [15].</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*oEKlSAnqhJim7cSoRBecsw.png" /><figcaption>Figure 1. Blockchain Use Cases [16]</figcaption></figure><p>Based on the Figure 1. Shows Blockchain-agnostic protocols enable cross-blockchain or cross-chain communication between arbitrary distributed ledger technologies [16].<br>Like cryptocurrencies, NFTs are issued on a blockchain, and are used to designate ownership of a certain asset. Unlike cryptocurrency, NFTs are not fungible, meaning each NFT is unique and not interchangeable with another NFT. For the first time, content on the internet in the form of an NFT can be definitively owned by a specific person independent of a centralized intermediary, and this is unlocking exciting opportunities for digital commerce and engagement [6].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*EVC_4XP6kyhQ_nMs9q_AXA.png" /><figcaption>Figure 2. Polkadot Stack [16]</figcaption></figure><p>Figure 2. Shows Collators transaction and Validator are two important core modules in the Polkadot stack. The Polkadot network has several entities engaged in handling transactions: collator, validator, nominator, and fisherman[16].</p><p>…</p><p>2. Methods<br>2.1 Streaming Music on Web2.0</p><p>2.2 Streaming Music on Web3.0</p><p>2.3 Smart Contract</p><p>2.3 Non-Fungible</p><p>2.4 Consensus and Tokenomics</p><p>2.5 Standards</p><p>2.6 Interoperability</p><p>2.7 Fee</p><p>2.8 DAO</p><p>2.9 Royalty Management</p><p>2.10 Label Management</p><p>2.11 Properties</p><p>2.12 Comparison of Music Bllockchain Platforms</p><p>3. Discussion</p><p>3.1 The phenomenon of the AI music generator</p><p>3.2 Royalty Settlement</p><p>3.3 Non-profit Sale</p><p>3.4 Geographic difficulties</p><p>3.5 MFS Architecture</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*7hSjWe6IrinalTMoXouHpg.png" /><figcaption>Figure 6. Proposed Race Branches</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j3g5FATCb1HZ_rYFNkx6Ug.png" /><figcaption>Figure 7. MFS Architecture</figcaption></figure><p>4. Open Challenges and Future Research Direction</p><p>…</p><p>5. Conclusion</p><p>It is welcomed to make a Music platform based on blockchain with 4S40 features. Commerce is evolving, and innovations like crypto and NFTs are likely to shape entertainment and other communities. In the future. NFTs represent a deeper and more innovative way for fans to engage and offer potential new revenue streams for organizations. However, there are many considerations to consider when integrating NFTs since it is a new field. The 21MFS Platform provisioned platform offers an engaging and immersive NFT music appreciation experience that is endless. We’ve leveraged the unique qualities of NFTs to create engaging experiences that connect fans to the music they love in new and exciting ways. Risks in a platform that works based on proposed work can come from protocols or Unique Network. Also, bugs and poor governance can become DAO governance.</p><p>6. References<br>[1]: [Unique Network Technical Paper](<a href="https://github.com/UniqueNetwork/techpaper">https://github.com/UniqueNetwork/techpaper</a>)<br>[2]: Unchained Music. (n.d.). Unchainedmusic.Io. Retrieved June 5, 2023, from <a href="https://unchainedmusic.io/">https://unchainedmusic.io/</a><br>[3]: [Brother Music Platform Token Whitepaper](<a href="https://bmpbrave.com/BMP%20WhitePaper_ENG.pdf">https://bmpbrave.com/BMP%20WhitePaper_ENG.pdf</a>)<br>[4]: Invest in music. (n.d.). Royal.Io. Retrieved June 5, 2023, from <a href="https://royal.io/">https://royal.io/</a><br>[5]: OriginTrail Parachain — Bringing real world assets/paper_images to Polkadot. (n.d.). Origintrail.Io. Retrieved May 30, 2023, from <a href="https://parachain.origintrail.io/whitepaper">https://parachain.origintrail.io/whitepaper</a><br>[6]: [Visan NFT Whitepaper](<a href="https://usa.visa.com/content/dam/VCOM/regional/na/us/Solutions/document">https://usa.visa.com/content/dam/VCOM/regional/na/us/Solutions/document</a>s/visa-nft-whitepaper.pdf)<br>[7]: [EIP-4337](<a href="https://eips.ethereum.org/EIPS/eip-4337">https://eips.ethereum.org/EIPS/eip-4337</a>)<br>[8]: Smart Contracts alliance (2016). Smart Contracts 12 Use Cases for Business &amp; Beyond. Chamber of Digital Commerce. — references — scientific research publishing. (n.d.). Scirp.org. Retrieved July 22, 2023, from <a href="https://www.scirp.org/%28S%28351jmbntvnsjt1aadkposzje%29%29/reference/references">https://www.scirp.org/%28S%28351jmbntvnsjt1aadkposzje%29%29/reference/references</a>papers.aspx?referenceid=2905139<br>[9]: Martin, S., Szekely, B., &amp; Allemang, D. (n.d.). The Rise of the Knowledge Graph. O’Reilly Media.<br>[10]: Hewa, T. M., Hu, Y., Liyanage, M., Kanhare, S. S., &amp; Ylianttila, M. (2021). Survey on blockchain-based smart contracts: Technical aspects and future research. IEEE Access: Practical Innovations, Open Solutions, 9, 87643–87662. <a href="https://doi.org/gn8f8x">https://doi.org/gn8f8x</a><br>[11]: Choi, K. (2021). Bimodal music subject classification via context-dependent language models. In Diversity, Divergence, Dialogue (pp. 68–77). Springer International Publishing. <a href="https://doi.org/kcnq">https://doi.org/kcnq</a><br>[12]: Fergencs, T., &amp; Meier, F. (2021). Engagement and usability of conversational search — A study of a medical resource center chatbot. In Diversity, Divergence, Dialogue (pp. 328–345). Springer International Publishing. <a href="https://doi.org/kcns">https://doi.org/kcns</a><br>[13]: Graus, M. P., &amp; Ferwerda, B. (2021). The moderating effect of active engagement on appreciation of popularity in song recommendations. In Diversity, Divergence, Dialogue (pp. 364–374). Springer International Publishing. <a href="https://doi.org/gjjm7z">https://doi.org/gjjm7z</a><br>[14]: Lam, L., &amp; Seidel, M.-D. L. (2020). Hypergrowth exit mindset: Destroying societal wellbeing through venture capital biased social construction of value. Journal of Management Inquiry, 29(4), 471–474. <a href="https://doi.org/ghf56f">https://doi.org/ghf56f</a><br>[15]: Li, X., Wang, Z., Leung, V. C. M., Ji, H., Liu, Y., &amp; Zhang, H. (2022). Blockchain-empowered data-driven networks: A survey and outlook. ACM Computing Surveys, 54(3), 1–38. <a href="https://doi.org/kcn9">https://doi.org/kcn9</a><br>[16]: Belchior, R., Vasconcelos, A., Guerreiro, S., &amp; Correia, M. (2020). A survey on blockchain interoperability: Past, present, and future trends. <a href="https://doi.org/kcpp">https://doi.org/kcpp</a><br>[17]: Sunray, E. (2021). Sounds of science: Copyright infringement in AI music generator outputs. Catholic University Journal of Law and Technology, 29(2), 185–218. <a href="https://scholarship.law.edu/jlt/vol29/iss2/9/">https://scholarship.law.edu/jlt/vol29/iss2/9/</a><br>[18]: AI-generated music and copyright. (n.d.). Clifford Chance. Retrieved May 30, 2023, from <a href="https://www.cliffordchance.com/insights/resources/blogs/talking-">https://www.cliffordchance.com/insights/resources/blogs/talking-</a><br>tech/en/articles/2023/04/ai-generated-music-and-copyright.html<br>[19]: van Pelt, R., Jansen, S., Baars, D., &amp; Overbeek, S. (2021). Defining blockchain governance: A framework for analysis and comparison. Information Systems Management, 38(1), 21–41. <a href="https://doi.org/gm2m6b">https://doi.org/gm2m6b</a><br>[20]: Gavin, W. (2016). Whitepaper [Polkadot.network/whitepaper](<a href="https://polkadot.network/whitepaper/">https://polkadot.network/whitepaper/</a>)<br>[21]: Music streaming worldwide — statistics &amp; facts [Internet]. Statista. [cited 2023 Jul 23]. Available from: <a href="https://www.statista.com/topics/6408/music-streaming/">https://www.statista.com/topics/6408/music-streaming/</a><br>[22]: Music streaming statistics in 2023 (US &amp; global data) [Internet]. Musical Pursuits. 2022 [cited 2023 Jul 23]. Available from: <a href="https://musicalpursuits.com/music-streaming/">https://musicalpursuits.com/music-streaming/</a><br>[23]: Digital, Culture, Media, Sport Committee. Music streaming must modernise. Is anybody listening? [Internet]. Shorthandstories.com. 2021 [cited 2023 Jul 23]. Available from: <a href="https://ukparliament.shorthandstories.com/music-streaming-must-modernise-">https://ukparliament.shorthandstories.com/music-streaming-must-modernise-</a>DCMS-report/index.html<br>[24]: Interactive digital studies major [Internet]. Uni.edu. [cited 2023 Jul 24]. Available from: <a href="https://ids.uni.edu/loudsoundlogic/how-do-artists-make-money-on-spotify-">https://ids.uni.edu/loudsoundlogic/how-do-artists-make-money-on-spotify-</a>soundcloud<br>[25]: Musicoin [Internet]. Musicoin.org. [cited 2023 Jul 24]. Available from:<br><a href="https://musicoin.org/">https://musicoin.org</a></p><p><a href="https://doi.org/10.5281/zenodo.8023208"><em>To gain full access to the paper</em></a></p><p><a href="https://scienft.com/nfts/156"><em>NFT address of paper</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6329477d8f07" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the Landscape of Regenerating Finance with Digital Transformation]]></title>
            <link>https://medium.com/aimonks/understanding-the-landscape-of-regenerating-finance-with-digital-transformation-2e95508ddc0c?source=rss-becac8404bb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e95508ddc0c</guid>
            <category><![CDATA[decentralized-finance]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[regenerative-finance]]></category>
            <category><![CDATA[sustainability]]></category>
            <dc:creator><![CDATA[Arman Riazi]]></dc:creator>
            <pubDate>Mon, 15 Jan 2024 21:14:59 GMT</pubDate>
            <atom:updated>2024-01-22T16:27:39.947Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Abstract</strong></p><p>In today’s rapidly evolving financial landscape, regenerative finance is a topic that has generated a lot of interest. This article is an overview of carbon offsetting, digital transformation, and natural climate solutions. ReFi is still in early stages of development; it lacks a precise definition of what constitutes a ReFi project and how its various parts work together to achieve the overall goals. It is not well defined, but fortunately, web3 registry networks, which are decentralized networks based on blockchain technology, are on the horizon. They provide a strong infrastructure for project registration and impact tracking, allowing regenerative finance to reach its full potential.</p><p>In recent times, a burgeoning discourse has emerged concerning the worldwide ramifications of greenhouse gas emissions, inciting demands for digital transformation to ascertain the technology of system integrity that is apt to solve global quandaries. Furthermore, we provide a collection of principles derived from the standards and protocols on regenerative economics for the purposeful overview of ReFi ecosystems.</p><p><strong>Keywords</strong>: #Carbon Credit #Regenerative Finance #Digital Transformation #Money and Sustainability</p><h3>1. Introduction</h3><p>Regenerative finance (ReFi) also overlaps with the decentralized science (DeSci) movement, ReFi is a set of tools and ideas built on top of blockchains, that aim to create economies which are regenerative, rather than extractive or exploitative. Eventually, extractive systems deplete the resources available and collapse; without regenerative mechanisms, they lack resilience [1].</p><p>ReFi operates on the assumption that the creation of monetary value must be decoupled from the unsustainable extraction of resources from our planet and communities. regenerative activities like planting trees, removing plastic from the ocean, or restoring a degraded ecosystem. Facilitate large-scale collaboration on global issues such as climate change and biodiversity loss [1].</p><p>Regenerative finance doesn’t refer to any specific cryptocurrency; rather, it is a movement toward mitigating climate change and improving equality [16].</p><p>ReFi has the potential to reshape the global economy and make tangible impacts on the lives of people and societies. ReFi has the potential to provide solutions for global poverty, healthcare, education, and a myriad of social issues. The capabilities of purpose-driven missions, such as impact investing, are elevated through ReFi’s technology [32].</p><p>The focus of regenerative finance is on initiatives that have the potential to go beyond addressing existing problems and actively work to restore and rebuild natural systems and build resilience for the future [33].</p><p>ReFi stands for Regenerative Finance and refers to a large-scale financial system that operates in a non-extractive way. A portion of the value generated and transferred flows back to the planet, and climate-positive actions become financially rewarding [34].</p><p>ReFi stands for Regenerative Finance, and it broadly relates to a movement aiming to use finance as a way to support regenerative and restorative outcomes in social, environmental, and economic systems [35].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*caUhfCPVP8uGyN6TjuLSdg.png" /><figcaption>Figure 1. Diagram of impact: From conventional design to regenerative design [12]</figcaption></figure><p>Eight principles of a regenerative economy [14]:</p><p>1. Edge effect abundance</p><p>2. Seeks balance</p><p>3. Empowered participation</p><p>4. Views wealth holistically</p><p>5. Innovative adaptive responsive</p><p>6. Robust circulation</p><p>7. Honors place &amp; community</p><p>8. In right relationship [14]</p><p>Sustainability vs Regenerative</p><p>Regenerative is seeking strategies for less harmful social and environmental practices (“do less bad”) to achieve competitive advantage rather than “doing more good.”. Sustainable companies aim to maintain the current state of natural systems in the present: they focus on reducing negative impact, preventing further degradation, and conserving resources [13].</p><h3>2.Problem Statement</h3><p>The planetary boundary framework, while providing a useful model for measuring change, is not fully accepted by all scientists. Some note that because the nine boundaries are all so deeply interconnected, it can be challenging to separate them out and evaluate each individually in a meaningful way. This is especially true for land system change, which underpins and influences nearly every other boundary [26]. Another criticism is that the land system boundary focuses on forests exclusively, and not on any other ecosystem type [26].</p><p>Companies that produce and sell major agricultural commodities to address deforestation within their operations and supply chains. Tools such as TRASE now provide supply chain mapping, but they don’t yet have the capacity to monitor at the detailed scales needed to change industries and halt deforestation [27].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*gjAipCCVqEGiZ4Ft3Q6gIw.png" /><figcaption>Figure 2. Planetary Boundary (PB) [27].</figcaption></figure><p>The green zone is the safe operating space, the yellow represents the zone of uncertainty (increasing risk), and the red is a high-risk zone. The planetary boundary itself lies at the intersection of the green and yellow zones. The control variables have been normalized for the zone of uncertainty; the center of the figure therefore does not represent values of zero for the control variables. The control variable shown for climate change is atmospheric CO2 concentration. Processes for which global-level boundaries cannot yet be quantified are represented by gray wedges; these are atmospheric aerosol loading, novel entities, and the functional role of biosphere integrity [26].</p><p>Three of the PBs (climate change, stratospheric ozone depletion, and ocean acidification) remain essentially unchanged from the earlier analysis [26].</p><p>To gain access to the full article please check the <a href="https://armanriazi.github.io/publications"><em>website</em></a><em> </em>out.</p><p>3.Regenerative Finance</p><p>3.1 Regenerative Finance Economic</p><p>3.2 Environmental, Social, and Governance</p><p>3.3 Digital Transformation</p><p>4. Natural Climate Solutions</p><p>4.1 Offsetting</p><p>4.2 Put a Price on Nature</p><p>5. Blockchain</p><p>5.1 Re-fungibility</p><p>5.2 Fungible Collection Mode</p><p>5.3 Carbon Offset Solution</p><p>5.4 Tokenization</p><p>6. Carbon Markets</p><p>6.1 Compliance Market</p><p>6.2 Voluntary Market</p><p>6.3 Real Carbon Credit</p><p>7. Standards</p><p>8. Protocols</p><p>9. Law and Regulatory</p><p>10. Future Vision</p><p>11. Conclusion</p><p>It seems that the concept of ReFi is a universal phenomenon that can be enabled through collaboration in SDG. From technology, investments, and legislation to the conservation of natural resources, they are all involved in the future and a good quality of life. Short- or medium-term strategies should be set based on long-term goals. The aim of this article is to acquaint individuals with the ReFi ecosystem by presenting a roadmap to the relevant stakeholders.</p><p>Due to the inherent risks expounded in this investigation, the persistent issues of greenhouse gas emissions, energy inefficiency, and refusal to employ state-of-the-art technologies endure. The optimal approach to address these predicaments involves holding both individuals and corporations accountable for the deleterious consequences. Though the complete elimination of this quandary in the immediate future seems implausible, targeted measures could be undertaken to mitigate the carbon footprint. By fostering awareness of the ramifications, individuals can exercise increased vigilance and thereby circumvent this conundrum.</p><p>References</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e95508ddc0c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aimonks/understanding-the-landscape-of-regenerating-finance-with-digital-transformation-2e95508ddc0c">Understanding the Landscape of Regenerating Finance with Digital Transformation</a> was originally published in <a href="https://medium.com/aimonks">𝐀𝐈 𝐦𝐨𝐧𝐤𝐬.𝐢𝐨</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using ACO Algorithm to Improve Performance for Container-based Scientific Workflows]]></title>
            <link>https://armanriazi-github-io.medium.com/articl-project-59717f2d8992?source=rss-becac8404bb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/59717f2d8992</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[cloudsim]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[ant-colony-optimization]]></category>
            <dc:creator><![CDATA[Arman Riazi]]></dc:creator>
            <pubDate>Mon, 15 Jan 2024 20:38:49 GMT</pubDate>
            <atom:updated>2024-01-15T21:03:08.980Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*lyROVohIpRMhHvx1enL6Mg.png" /><figcaption>Java Code: doi.org/10.5281/zenodo.7715653</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*7shXdOWwtOeuiBfdHmQEGg.png" /><figcaption>Article: doi.org/10.5281/zenodo.8105650</figcaption></figure><h3>Abstract</h3><p>Nowadays with the development of technology, we watch an increase in the number of users using cloud computing services. The process of increasing demand, the need for intelligent supply and demand cycle, better resource management, better utilization of resources is necessary. The results indicate competition from the cycle leads to a complex challenge for selecting and scheduling tasks to provide composite services in the cloud. One of the most important issues in this field is load balancing. How to choose idle resources from a set of resources, overcoming compositional constraints, determines the importance of scheduling and resource allocation. These are NP-Hard issues. State-of-the-art architecture in the field of cloud computing for the implementation of Scientific Workflows that can be implemented in a distributed manner is becoming increasingly considered in other sciences related to cloud computing. The distinction and competition of cloud service providers to publish services with more profit and better quality to customers are summarized in features such as “Scalability, Stability, High availability, Fault tolerance”. By providing new solutions and services for using specialists in other sciences, we can see the utilization of cloud computing Infrastructure and services in the fields of industry, commerce, health, and emergency applications. The possibility of conducting scientific workflows using virtual machines” and containers is a goal that has been addressed in the proposed architecture. The load balancing in the form of containers at the level of virtual machines using the ant colony optimization(ACO) algorithm is one of the important goals and issues that have been covered and solutions for utilization as much as possible has been explained. According to previous studies, there is no comprehensive or stable architecture that can balance scientific workflows using the algorithm ACO at the container virtualization level. By providing a simulator environment and testing several samples with different parameters then estimated the efficiency of the ACO and default algorithm of CloudSIM e.g., first-come-first-serve (FCFS). In the case of fifty, hundred samples of “montage” scientific workflow, which is considered as the average load rate, balancing the workload of the containers on the virtual machine with the ACO has better results than the FCFS. If the value of the beta parameter of the ACO is assigned by zero, the algorithm will be trapped to the local optimal. In the case of a thousand sample, which is interpreted as a large amount of workload, if a “cybershake” workflow is used finally the results will be the same in all performance evaluation indicators. The results indicate that on average, the ACO has desired performance of almost 50% better than FCFS in the most of scenarios regarding proposed architecture and using cybershake and montage workflows.</p><p>Keywords: #CloudComputing #ContainerAllocation #Workflow #ACO #ContainerAllocation #DevOps #LoadBalancer #Scheduler</p><blockquote><em>Additional Experimental Research: CloudSim-Workflow-Function-Container-Plus (Toward ServerMix) on my </em><a href="https://github.com/armanriazi/Cloudsim-Workflow-Function-Container-ACO"><em>Github page</em></a><em>.</em></blockquote><p><strong>Pros:</strong></p><ul><li>Simulation of cost and performance</li><li>Scalability: Container is very scalable than the virtual machines</li><li>Elasticity: with separating logical code and data</li><li>Decrease overhead</li><li>Decrease the start time of tasks</li><li>Fixed data dependency</li><li>Resource management</li><li>Workflow Engine management</li><li>Resource Management</li></ul><p><strong>Cons:</strong></p><ul><li>Lack of clean code and more refactoring.</li><li>Exclude of design patterns, modular</li><li>Not using Maven and Unit Test</li></ul><p><strong>Concepts:</strong></p><ul><li>Workflow: correspond with Function Composition on the simulation environment.</li><li>Function as a Service(FaaS): Lambda or Cloud Function on the production environment.</li><li>Cloudlet : the task of the client or job of workflow</li><li>ACO Scheduler: Ant colony optimization</li><li>Serverfull: include virtual machine/on-premises</li><li>Serverless: no server, Event-driven, Provisioning, Scalability, FaaS</li><li>ServerMix: The proposed model included both of them. In implementing simulation we did not use FaaS or Lambda functions but we have some situations and marks of the Serverless as a kind of theoretical because we implemented with the capability of elasticity that is one of the Serverless features. on the other hand, we are going to need event-driven and arrow functions in this java program.</li></ul><p><strong>Target:</strong> Running Montage workflow base on the container. We have two repo for implementing: Container base on Vm: (<a href="https://github.com/armanriazi/cloudsim-workflow-function-container">Cloudsim-Workflow-Function-Container</a>),(<a href="https://github.com/armanriazi/Cloudsim-Workflow-Function-Container-ACO">Cloudsim-Workflow-Function-Container-ACO</a>)</p><figure><img alt="image" src="https://cdn-images-1.medium.com/proxy/1*smd8x7xJ1aGlcbs3ATrbbQ.png" /></figure><p>Container base on host:(<a href="https://github.com/armanriazi/Workflow-Function-Container-Plus">CloudSim-Workflow-Function-Container-Plus</a>), (<a href="https://github.com/armanriazi/Cloudsim-Workflow-Function-Container-ACO">Cloudsim-Workflow-Function-Container-ACO</a>)</p><figure><img alt="Montage-Workflow" src="https://cdn-images-1.medium.com/proxy/1*HpB4119tw_aERjoMRyjtGQ.png" /></figure><figure><img alt="Part of Class Diagram" src="https://cdn-images-1.medium.com/proxy/1*QSosVKTZTz-XbnSTt9cGGQ.png" /></figure><p><strong>Part of class diagram:</strong> ContainerCloudsim class diagram(unpublished as a personal use-case)</p><figure><img alt="Part of Class Diagram" src="https://cdn-images-1.medium.com/proxy/1*2Hta7uuNAGFpi-3nf6B-XA.png" /></figure><p><strong>Sequential diagram of WFC architecture:</strong></p><figure><img alt="Part of Class Diagram" src="https://cdn-images-1.medium.com/proxy/1*vRm-lDsQSPdz65uQdJLJUg.png" /></figure><p><strong>Proposed Architecture:</strong> WFC has transparency and clarity on architecture and implemented java code.</p><p><strong>Prerequisites:</strong> Resolve project libraries include: commons-math3–3.2 | 3–6.1, flanagan, jdom-2.0.0, opencsv-2.3 (maybe) <strong>Results with montage Num.X:</strong> <a href="https://drive.google.com/file/d/1VIpOwOa1r9XPfNfGD7re6VazoJchVezn/preview">Season 6</a></p><p><strong>Contact me:</strong> Let me know how can I help you with developing and researching. I am eager to your suggestion.</p><p><a href="https://armanriazi.github.io/public/university/master/"><strong><em>Full access to all references and downloadable information</em></strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59717f2d8992" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rust 2021 Blockchain]]></title>
            <link>https://armanriazi-github-io.medium.com/rust-2021-blockchain-12c2d649e63d?source=rss-becac8404bb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/12c2d649e63d</guid>
            <category><![CDATA[btc]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Arman Riazi]]></dc:creator>
            <pubDate>Sat, 09 Jul 2022 11:58:26 GMT</pubDate>
            <atom:updated>2022-07-09T11:58:26.263Z</atom:updated>
            <content:encoded><![CDATA[<p>The repo is a <strong>prerequisite of the Substrate-Framework</strong> and it would be nicer to practice too.</p><p>The repo is included Rust syntax, configuration and the goal of creating scratch codes like one is becuase of providing <strong>testbed environment of Blockchain</strong>.</p><p>The Next reason is to using some <strong>features of Rust-Lang</strong> that I had wanted to implement it after learning Rust.</p><p>Used json in the main runner of the project so that consume <strong>json</strong> transactions as a <strong>offchain</strong> blockchain.</p><p>As you follow materials you can see (future work) which means you can add these concepts to the project. I have some <strong>idea</strong> that you can affort on it to completing future works.</p><p><em>Smart Contracts, MultiSignature, RPC, Make A Better CLI, and something that you can implementing</em> (Do not worry sice most of your works will merge to main branch. We will not create a framework or complete Blockchain because we just need to <strong>learning</strong> more and used it use-cases)</p><h3>The difference between the current work and the prev works<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#the-difference-between-the-current-work-and-the-prev-works">¶</a></h3><blockquote><em>I have tried to use fundamental concepts correctly, for example, all of us know any block have not any copy so because of it we are calling blockchain! Unlike many repositories on GitHub(testbed/scratched projects-non productive) that almost use Copy/Clone features of Rust-Lang. In the following, there are some features that cause a different project.</em></blockquote><blockquote><em>Currently Status: Under Refactoring</em></blockquote><h3>How To Contribute <a href="https://github.com/armanriazi/armanriazi/blob/main/HowToContribute.md">Easy</a><a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#how-to-contribute-easy">¶</a></h3><h3>Instructions for working with<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#instructions-for-working-with">¶</a></h3><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;DIFFICULTY={difficulty} cargo {mode} {file name}</pre><blockquote><em>{difficulty}: (optional-key-env) value default 0x00ffffffffffffffffffffffffffffff.It must be 32 byte.</em></blockquote><blockquote><em>{mode}: macro, string, file/ default mode is on the macrojson mode.</em></blockquote><blockquote><em>{macro, string} there is in project and you can not access or manipulate except by getting the project. serde_json support string and macro based on called library. {file} json file is external .json file that you can set it for command line</em></blockquote><blockquote><em>{file name} index directory of the project sample-bolocks.json</em></blockquote><blockquote><em>Example:</em></blockquote><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;cargo build<br>DIFFICULTY=0x00000fffffffffffffffffffffffffff time cargo run file sample-bolocks.json<br>DIFFICULTY=0x00000fffffffffffffffffffffffffff time cargo run macrojson<br>DIFFICULTY=0x00000fffffffffffffffffffffffffff time cargo run stringjson<br>time cargo run<br>cargo watch -x run</pre><p><em>Using time and watch is optional and depends on your purpose</em></p><h3>Features<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#features">¶</a></h3><ul><li>[✓] Modular</li><li>[✓] UnitTest(semi:future work)</li><li>[✓] Customized Error Handling</li><li>[✓] Json &amp; String Data Deserialized</li><li>[✓] Closure(Functional Programming)</li><li>[✓] Cryptography-Hashing Alogrithm SHA-256</li><li>[✓] Configuration Files(semi- devOps)</li></ul><h3>Used Concepts<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#used-concepts">¶</a></h3><h4>- [✓] Memoization•Lazy•Evaluation<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-memoizationlazyevaluation">¶</a></h4><blockquote><em>We can create a struct that will hold the closure and the resulting value of calling the closure.</em></blockquote><blockquote><em>The struct will execute the closure only if we need the resulting value, and it will cache the resulting value so the rest of our code doesn’t have to be responsible for saving and reusing the result.</em></blockquote><blockquote><em>FnOnce consumes the variables it captures from its enclosing scope, known as the closure’s environment. To consume the captured variables, the closure must take ownership of these variables and move them into the closure when it is defined. The Once part of the name represents the fact that the closure can’t take ownership of the same variables more than once, so it can be called only once.</em></blockquote><blockquote><em>FnMut can change the environment because it mutably borrows values.</em></blockquote><blockquote><em>Fn borrows values from the environment immutably. FnOnce: takes the whole value. FnMut: takes a mutable reference. Fn: takes a regular reference.</em></blockquote><h4>- [✓] Coercion<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-coercion">¶</a></h4><blockquote><em>Deref coercion is a convenience that Rust performs on arguments to functions and methods. Deref coercion works only on types that implement the Deref trait. Deref coercion converts such a type into a reference to another type. For example, deref coercion can convert &amp;String to &amp;str because String implements the Deref trait such that it returns &amp;str.</em></blockquote><blockquote><em>The number of times that Deref::deref needs to be inserted is resolved at compile time, so there is no runtime penalty for taking advantage of deref coercion! Similar to how you use the Deref trait to override the * operator on immutable references, you can use the DerefMut trait to override the * operator on mutable references.the Drop trait is almost always used when implementing a smart pointer. For example, when a Box is dropped it will deallocate the space on the heap that the box points to.</em></blockquote><blockquote><em>Note that we didn’t need to call the drop method explicitly.</em></blockquote><h4>- [✓] DST•Or•Unsizedtype<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-dstorunsizedtype">¶</a></h4><blockquote><em>DSTs or unsized types’: str(but not &amp;str-So although a &amp;T is a single value that stores the memory address of where the T is located, a &amp;str is two values: the address of the str and its length. Rust has a particular trait called the Sized trait to determine whether or not a type’s size is known at compile time. This trait is automatically implemented for everything whose size is known at compile time. In addition, Rust implicitly adds a bound on Sized to every generic function.</em></blockquote><h4>- [✓] Operation<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-operation">¶</a></h4><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;-&gt; Methods are functions that are coupled to some object.</pre><blockquote><em>From a syntactic point of view, these are just functions that don’t need to specify one of their arguments. Rather than calling open() and passing a File object in as an argument (read(f, buffer)), methods allow the main object to be implicit in the function call (f.read(buffer)) using the dot operator.</em></blockquote><blockquote><em>There are a number of theoretical differences between methods and functions, but a detailed discussion of those computer science topics is available in other books. Briefly, functions are regarded as pure, meaning their behavior is determined solely by their arguments. Methods are inherently impure, given that one of their arguments is effectively a side effect. These are muddy waters, though. Functions are perfectly capable of acting on side effects themselves. Moreover, methods are implemented with functions. And, to add an exception to an exception, objects sometimes implement static methods, which do not include implicit arguments. To define methods, Rust programmers use an impl block</em></blockquote><h4>- [✓] Borrowchecker<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-borrowchecker">¶</a></h4><blockquote><em>The borrow checker checks that all access to data is legal, which allows Rust to prevent safety issues. Learning how this works will, at the very least, speed up your development time by helping you avoid run-ins with the compiler. More significantly though, learning to work with the borrow checker allows you to build larger software systems with confidence. It underpins the term fearless concurrency.</em></blockquote><h4>- [✓] Borrowchecker•Lifetime<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-borrowcheckerlifetime">¶</a></h4><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;-&gt; Lifetime=Timetolive=Subset of their scope</pre><blockquote><em>Make hypotheses about whether or not your experiments will pass the borrow checker before you compile reference in Rust has a lifetime, which is the scope for which that reference is valid. Most of the time, lifetimes are implicit and inferred, just like most of the time, types are inferred. We must annotate types when multiple types are possible. In a similar way, we must annotate lifetimes when the lifetimes of references could be related in a few different ways.</em></blockquote><blockquote><em>The main aim of lifetimes is to prevent dangling references, which cause a program to reference data other than the data it’s intended to reference. All references in Rust have a lifetime, even if they are not explicitly annotated. The compiler is capable of implicitly assigning lifetimes.</em></blockquote><blockquote><em>A value’s lifetime is the period when accessing that value is valid behavior. A function’s local variables live until the function returns, while global variables might live for the life of the program.</em></blockquote><blockquote><em>The notion of ownership is rather limited. An owner cleans up when its values’ lifetimes end.</em></blockquote><blockquote><em>Although every parameter has a lifetime, these checks are typically invisible as the compiler can infer most lifetimes by itself.</em></blockquote><blockquote><em>All values bound to a given lifetime must live as long as the last access to any value bound to that lifetime.</em></blockquote><blockquote><em>No lifetime annotations are required when calling a function.</em></blockquote><blockquote><em>Lifetime annotations don’t change how long any of the references live. Just as functions can accept any type when the signature specifies a generic type parameter, functions can accept references with any lifetime by specifying a generic lifetime parameter.</em></blockquote><blockquote><em>Lifetime annotations describe the relationships of the lifetimes of multiple references to each other without affecting the lifetimes.</em></blockquote><blockquote><em>The lifetime annotations indicate that the references first and second must both live as long as that generic lifetime.</em></blockquote><blockquote><em>Lifetimes on function or method parameters are called input lifetimes, and lifetimes on return values are called output lifetimes.</em></blockquote><blockquote><em>Although every parameter has a lifetime, these checks are typically invisible as the compiler can infer most lifetimes by itself</em></blockquote><blockquote><em>All values bound to a given lifetime must live as long as the last access to any value bound to that lifetime.</em></blockquote><blockquote><em>No lifetime annotations are required when calling a function.</em></blockquote><blockquote><em>Using two lifetime parameters (a and b) indicates that the lifetimes of i and j are decoupled.</em></blockquote><blockquote><em>fn add_with_lifetimes&lt;’a, ‘b&gt;(i: &amp;’a i32, j: &amp;’b i32) -&gt; i32 {}</em></blockquote><blockquote><em>Lifetime of that usage:</em></blockquote><blockquote><em>the LOC(‘existence time’ or Line of code) between when a location is first used in a certain way, and when that usage stops.</em></blockquote><blockquote><em>Lifetime of that value:</em></blockquote><blockquote><em>the LOC (or actual time) between when a value is created, and when that value is dropped.</em></blockquote><blockquote><em>Might be useful when discussing open file descriptors, but also irrelevant here.</em></blockquote><blockquote><em>Ultimately, lifetime syntax is about connecting the lifetimes of various parameters and return values of functions. Once they’re connected, Rust has enough information to allow memory-safe operations and disallow operations that would create dangling pointers or otherwise violate memory safety.</em></blockquote><h4>- [✓] Dangle<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-dangle">¶</a></h4><blockquote><em>The main aim of lifetimes is to prevent dangling references.which has an outer scope and an inner scope. In return section of a function primitive types need to define as (&amp;’a or &amp;’static)</em></blockquote><h4>- [✓] Generic<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-generic">¶</a></h4><blockquote><em>You might be wondering whether there is a runtime cost when using generic type parameters. The good news is that using generic types won’t make your run any slower than it would with concrete types.</em></blockquote><blockquote><em>Rust accomplishes this by performing monomorphization of the code using generics at compile time. Monomorphization is the process of turning generic code into specific code by filling in the concrete types that are used when compile. Every programming language has tools for effectively handling the duplication of concepts.</em></blockquote><blockquote><em>In Rust, one such tool is generics. Generics are abstract stand-ins for concrete types or other properties. When we’re writing code, we can express the behavior of generics or how they relate to other generics without knowing what will be in their place when compiling and running the code.</em></blockquote><h4>Static•Dispatch(Passed)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#staticdispatchpassed">¶</a></h4><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;-&gt; Monomorphization</pre><blockquote><em>Dispatch is the mechanism to determine which specific version of code is actually run when it involves polymorphism. Two major forms of dispatch are static dispatch and dynamic dispatch. While Rust favors static dispatch, it also supports dynamic dispatch through a mechanism called ‘trait objects’. When Rust compiles this code, it performs monomorphization.</em></blockquote><blockquote><em>The monomorphized version of the code looks like the following. The generic Option is replaced with the specific definitions created by the compiler: versions of a polymorphic function (or any polymorphic entity) during compilation is called Monomorphization.</em></blockquote><blockquote><em>Because Rust compiles generic code into code that specifies the type in each instance, we pay no runtime cost for using generics. When the code runs, it performs just as it would if we had duplicated each definition by hand. The process of monomorphization makes Rust’s generics extremely efficient at runtime. This is opposed to dynamic dispatch</em></blockquote><h4>- [✓] Dynamic•Dispatch<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-dynamicdispatch">¶</a></h4><blockquote><em>The code that results from monomorphization is doing static dispatch, which is when the compiler knows what method you’re calling at compile time. This is opposed to dynamic dispatch, which is when the compiler can’t tell at compile time which method you’re calling. In dynamic dispatch cases, the compiler emits code that at runtime will figure out which method to call.</em></blockquote><blockquote><em>When we use trait objects, Rust must use dynamic dispatch. The compiler doesn’t know all the types that might be used with the code that is using trait objects, so it doesn’t know which method implemented on which type to call. Instead, at runtime, Rust uses the pointers inside the trait object to know which method to call. There is a runtime cost when this lookup happens that doesn’t occur with static dispatch. Dynamic dispatch also prevents the compiler from choosing to inline a method’s code, which in turn prevents some optimizations.</em></blockquote><h4>- [-] Blanket•Implementation<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-blanketimplementation">¶</a></h4><blockquote><em>Any implementation where a type appears uncovered. impl Foo for T, impl Bar for T, impl Bar&gt; for T, and impl Bar for Vec are considered blanket impls.</em></blockquote><blockquote><em>We can also conditionally implement a trait for any type that implements another trait. Implementations of a trait on any type that satisfies the trait bounds are called blanket implementations and are extensively used in the Rust standard library. For example, the standard library implements the ToString trait on any type that implements the Display trait.</em></blockquote><h4>- [✓] Bound(syntax)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-boundsyntax">¶</a></h4><blockquote><em>Bounds are constraints on a type or trait. For example, if a bound is placed on the argument a function takes, types passed to that function must abide by that constraint.</em></blockquote><h4>- [✓] Trait<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-trait">¶</a></h4><blockquote><em>We can use traits to define shared behavior in an abstract way. We can use trait bounds to specify that a generic type can be any type that has certain behavior. Traits are similar to a feature often called interfaces in other languages, although with some differences.</em></blockquote><blockquote><em>What is a trait? A trait is a language feature that is analogous to an interface, protocol, or contract. If you have a background in object-oriented programming, consider a trait to be an abstract base class. If you have a background in functional programming, Rust’s traits are close to Haskell’s type classes these also support a form of inheritance that’s common in most object oriented languages. For now, though, the thing to remember is that traits represent common behavior (Or reusable codes like println!)that types opt into via the syntax impl Trait for Type.</em></blockquote><blockquote><em>After the method signature, instead of providing an implementation within curly brackets, we use a semicolon.</em></blockquote><blockquote><em>This interface consists of associated items, which come in three varieties: functions, types, constants.</em></blockquote><blockquote><em>All traits define an implicit type parameter Self that refers to “the type that is implementing this interface”.</em></blockquote><blockquote><em>Trait functions may omit the function body by replacing it with a semicolon. This indicates that the implementation must define the function. If the trait function defines a body, this definition acts as a default for any implementation which does not override it. Similarly, associated constants may omit the equals sign and expression to indicate implementations must define the constant value. Associated types must never define the type, the type may only be specified in an implementation.</em></blockquote><h4>- [✓] Polymorphism<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-polymorphism">¶</a></h4><blockquote><em>In a struct or enum, the data in the struct fields and the behavior in impl blocks are separated, whereas in other languages, the data and behavior combined into one concept is often labeled an object.However, trait objects are more like objects in other languages in the sense that they combine data and behavior.</em></blockquote><h4>- [✓] Unrolling<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-unrolling">¶</a></h4><blockquote><em>It is an optimization that removes the overhead of the loop controlling code and instead generates repetitive code for each iteration of the loop.</em></blockquote><h4>- [✓] Binding•Match<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-bindingmatch">¶</a></h4><blockquote><em>The compiler automatically references the Some, and since we’re borrowing, name is bound as ref name automatically as well. If we were mutating:</em></blockquote><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt; //https://blog.rust-lang.org/2018/05/10/Rust-1.26.html#nicer-match-bindings<br>// `self` has type `&amp;List`, and `*self` has type `List`, matching on a<br>// concrete type `T` is preferred over a match on a reference `&amp;T`<br>// after Rust 2018 you can use self here and tail (with no ref) below as well,<br>// rust will infer &amp;s and ref tail.</pre><h4>- [✗] Datarace•Rustaceans<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-dataracerustaceans">¶</a></h4><blockquote><em>Note: The opposite of referencing by using &amp; is dereferencing, which is accomplished with the dereference operator, *.</em></blockquote><h4>[-] Nan(philosophy)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-nanphilosophy">¶</a></h4><blockquote><em>Floating-point types include “not a number” values (represented in Rust syntax as NAN values) to handle these cases.</em></blockquote><blockquote><em>NAN values poison other numbers. Almost all operations interacting with NAN return NAN. Another thing to be mindful of is that, by definition, NAN values are never equal. Programming language design is often thought of in terms of which features you include, but the features you exclude are important too. Rust doesn’t have the null feature that many other languages have. Null is a value that means there is no value there. In languages with null, variables can always be in one of two states: null or not-null. In his 2009 presentation “Null References: The Billion Dollar Mistake,” Tony Hoare, the inventor of null, has this to say: I call it my billion-dollar mistake. At that time, I was designing the first comprehensive type system for references in an object-oriented language. My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn’t resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years.</em></blockquote><blockquote><em>To program defensively, make use of the is_nan() and is_finite() methods. Inducing a crash, rather than silently proceeding with a mathematical error, allows you to debug close to what has caused the problem. The following illustrates using the is_finite()</em></blockquote><h4>- [✓] Duplication((literal)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-duplicationliteral">¶</a></h4><blockquote><em>Concept of copying the pointer, length, and capacity without copying the data probably sounds like making a shallow copy.</em></blockquote><blockquote><em>If we do want to deeply copy the heap data of the String, not just the stack data, we can use a common method called clone</em></blockquote><h4>- [✓] Semantic(literal)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-semanticliteral">¶</a></h4><blockquote><em>Primitive types are said to possess copy semantics, whereas all other types have move semantics. Adding more functionality (e.g., reference-counting semantics rather than move semantics) to types by wrapping these in other types typically reduces their run-time performance.</em></blockquote><h4>- [✓] Zero•Cost•Abstractions(literal)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-zerocostabstractionsliteral">¶</a></h4><blockquote><em>One of the ways this manifests is by not adding extra data around values within structs.</em></blockquote><h4>- [✓] Coherence(literal)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-coherenceliteral">¶</a></h4><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;-&gt; Orphan = Trait•External•Implement</pre><blockquote><em>But we can’t implement external traits on external types. For example, we can’t implement the Display trait on Vec within our aggregator crate, because Display and Vec are defined in the standard library and aren’t local to our aggregator crate. This restriction is part of a property of programs called coherence, and more specifically the orphan rule, so named because the parent type is not present. This rule ensures that other people’s code can’t break your code and vice versa.</em></blockquote><blockquote><em>Without the rule, two crates could implement the same trait for the same type, and Rust wouldn’t know which implementation to use.</em></blockquote><blockquote><em>Preserves contextual coherence of trace data from tasks/function/methods when logging.</em></blockquote><blockquote><em>For example new instance of a struct of course, as you probably already know, struct then you can just summerize your struct in a method.</em></blockquote><h4>- [✓] Jargon(literal)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-jargonliteral">¶</a></h4><blockquote><em>Functional programming jargon: “to cons x onto y” informally means to construct a new container instance by putting the element x at the start of this new container, followed by the container y.Other, more complex recursive data types are useful in various situations, but by starting with the cons list, we can explore how boxes let us define a recursive data type without much distraction.</em></blockquote><h4>- [✓] Refactor(literal)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-refactorliteral">¶</a></h4><blockquote><em>One alternative to refactoring is to simply copy values. Doing this often is typically frowned upon, however, but it can be useful in a pinch. Primitive types like integers are a good example of that. Primitive types are cheap for a CPU to duplicate — so cheap, in fact, that Rust always copies these if it would otherwise worry about ownership being moved.</em></blockquote><blockquote><em>Types can opt into two modes of duplication: cloning and copying.</em></blockquote><h4>- [✓] Pattern•Newtype<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-patternnewtype">¶</a></h4><blockquote><em>Using the Newtype Pattern to Implement External Traits on External Types ‘thin wrapper around the type’ : part of Vec is noticed. We can make a Wrapper struct that holds an instance of Vec; then we can implement Display on Wrapper and use the Vec value The downside of using this technique is that Wrapper is a new type, so it doesn’t have the methods of the value it’s holding. We would have to implement all the methods of Vec directly on Wrapper such that the methods delegate to self.0, which would allow us to treat Wrapper exactly like a Vec.</em></blockquote><blockquote><em>If we wanted the new type to have every method the inner type has, implementing the Deref trait (If we don’t want the Wrapper type to have all the methods of the inner type — for example, to restrict the Wrapper type’s behavior — we would have to implement just the methods we do want manually.)</em></blockquote><h4>- [✗] Pattern•Design•Interior(future work)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-patterndesigninteriorfuture-work">¶</a></h4><blockquote><em>Interior mutability is a design pattern in Rust that allows you to mutate data even when there are immutable references to that data; normally, this action is disallowed by the borrowing rules. To mutate data, the pattern uses unsafe code inside a data structure to bend Rust’s usual rules that govern mutation and borrowing.</em></blockquote><blockquote><em>RefCell type that follows the interior mutability pattern.</em></blockquote><blockquote><em>Unlike Rc, the RefCell type represents single ownership over the data it holds. So, what makes RefCell different from a type like Box? Recall the borrowing rules…</em></blockquote><blockquote><em>Similar to Rc, RefCell is only for use in single-threaded scenarios and will give you a compile-time error if you try using it in a multithreaded context. At any given time, you can have either (but not both of) one mutable reference or any number of immutable references.References must always be valid.</em></blockquote><h4>- [✗] Type•Wraper(future work)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-typewraperfuture-work">¶</a></h4><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;-&gt; Wrapper type = Reference-Counted Value = Shared Ownership = Track valid references</pre><blockquote><em>Use wrapper types, which allow more flexibility than what is available by default. These, however, incur costs at runtime to ensure that Rust’s safety guarantees are maintained. Another way to phrase this is that Rust allows programmers to opt in to garbage collection.</em></blockquote><h4>- [✗] Mem•Leak(future work)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-memleakfuture-work">¶</a></h4><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;-&gt; Managing Memory Leak</pre><blockquote><em>Rust’s memory safety guarantees make it difficult, but not impossible, to accidentally create memory that is never cleaned up (known as a memory leak). Preventing memory leaks entirely is not one of Rust’s guarantees in the same way that disallowing data races at compile time is, meaning memory leaks are memory safe in Rust.</em></blockquote><blockquote><em>We can see that Rust allows memory leaks by using Rc and RefCell: it’s possible to create references where items refer to each other in a cycle. This creates memory leaks because the reference count of each item in the cycle will never reach 0, and the values will never be dropped.</em></blockquote><p>- [✗] MEM•DOUBLEFREE(FUTURE WORK)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-memdoublefreefuture-work">¶</a></p><blockquote><em>This is a problem: when s2 and s1 (s2 is copied s1 means 2different pointer and the same data) go out of scope, they will both try to free the same memory. This is known as a double free error and is one of the memory safety bugs we mentioned previously. Freeing memory twice can lead to memory corruption, which can potentially lead to security vulnerabilities.</em></blockquote><h4>- [✗] Mem•Deallocating•or•RAII(future work)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-memdeallocatingorraiifuture-work">¶</a></h4><blockquote><em>Note: In C++, this pattern of deallocating resources at the end of an item’s lifetime is sometimes called Resource Acquisition Is Initialization (RAII). The drop function in Rust will be familiar to you if you’ve used RAII patterns.</em></blockquote><h4>- [✗] Thread(future work)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-threadfuture-work">¶</a></h4><blockquote><em>Which parts of your code on different threads will run. This can lead to problems, such as:</em></blockquote><blockquote><em>Race conditions, where threads are accessing data or resources in an inconsistent order Deadlocks, where two threads are waiting for each other to finish using a resource the other thread has, preventing both threads from continuing Bugs that happen only in certain situations and are hard to reproduce and fix reliably.</em></blockquote><h4>- [✗] Thread•Strateges(future work)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-threadstrategesfuture-work">¶</a></h4><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;-&gt; Priority Performance</pre><blockquote><em>Stealing_Join: execute code in parallel when there are idle CPUs to handle it.</em></blockquote><blockquote><em>When join is called from outside the thread pool, the calling thread will block while the closures execute in the pool. When join is called within the pool, the calling thread still actively participates in the thread pool. It will begin by executing closure A (on the current thread). While it is doing that, it will advertise closure B as being available for other threads to execute. Once closure A has completed, the current thread will try to execute closure B; if however closure B has been stolen, then it will look for other work while waiting for the thief to fully execute closure B. (This is the typical work-stealing strategy). Send is require because we have jump from quick func(thread a) to part func(thread b) frequently.</em></blockquote><blockquote><em>Atomic: types provide primitive shared-memory communication between threads, and are the building blocks of other concurrent types. This module defines atomic versions of a select number of primitive types, including AtomicBool, AtomicIsize, AtomicUsize, AtomicI8, AtomicU16, etc. Atomic types present operations that, when used correctly, synchronize updates between threads. Each method takes an Ordering which represents the strength of the memory barrier for that operation. These orderings are the same as the C++20 atomic orderings. For more information see the nomicon.</em></blockquote><blockquote><em>Atomic variables are safe to share between threads (they implement Sync) but they do not themselves provide the mechanism for sharing and follow the threading model of Rust. The most common way to share an atomic variable is to put it into an Arc (an atomically-reference-counted shared pointer). Atomic types may be stored in static variables, initialized using the constant initializers like AtomicBool::new. Atomic statics are often used for lazy global initialization.</em></blockquote><blockquote><em>Spin_Loop_Yeild also known as busy loop and spin loop-If you want to sleep pause a thread for short amounts of time, or if your application is sensitive to timing, use a spin loop</em></blockquote><h4>- [✗] Unsafe•Extern•Mangling(future work)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-unsafeexternmanglingfuture-work">¶</a></h4><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;&gt; Mangling is when a compiler changes the name we’ve given a function to a different name that contains more information for other parts of the compilation process to consume but is less human readable. Every programming language compiler mangles names slightly differently, so for a Rust function to be nameable by other languages, we must disable the Rust compiler’s name mangling.</pre><h4>- [✓] Interior•Mutability•Pattern<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-interiormutabilitypattern">¶</a></h4><p>RefCell: Lets us have many immutable borrows or one mutable borrow at any point in time. Mutating the value inside an immutable value is the interior mutability pattern. Interior mutability is a design pattern in Rust that allows you to mutate data even when there are immutable references to that data; normally, this action is disallowed by the borrowing rules. To mutate data, the pattern uses unsafe code inside a data structure to bend Rust’s usual rules that govern mutation and borrowing. RefCell type that follows the interior mutability pattern. Unlike Rc, the RefCell type represents single ownership over the data it holds. So, what makes RefCell different from a type like Box? Recall the borrowing rules, Similar to Rc, RefCell is only for use in single-threaded scenarios and will give you a compile-time error if you try using it in a multithreaded context. At any given time, you can have either (but not both of) one mutable reference or any number of immutable references.References must always be valid.</p><h4>- [✗] OOP•State•DesignPattern(future work)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-oopstatedesignpatternfuture-work">¶</a></h4><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;-&gt; We can used it for smart contracts so we will need to implemented smart contracts</pre><blockquote><em>Using the state pattern means when the business requirements of the program change, we won’t need to change the code of the value holding the state or the code that uses the value. We’ll only need to update the code inside one of the state objects to change its rules or perhaps add more state objects.</em></blockquote><blockquote><em>e.g Post type. This type will use the state pattern and will hold a value that will be one of three state objects representing the various states a post can be in — draft, waiting for review, or published. Changing from one state to another will be managed internally within the Post type. The states change in response to the methods called by our library’s users on the Post instance, but they don’t have to manage the state changes directly. Also, users can’t make a mistake with the states, like publishing a post before it’s reviewed.</em></blockquote><h4>- [✗] Superpower(future work)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-superpowerfuture-work">¶</a></h4><blockquote><em>if the Rust compiler doesn’t have enough information to be confident, it will reject the code. In these cases, you can use unsafe code to tell the compiler, “Trust me, I know what I’m doing.” The downside is that you use it at your own risk: if you use unsafe code incorrectly, problems due to memory unsafety, such as null pointer dereferencing, can occur.</em></blockquote><blockquote><em>You can take five actions in unsafe Rust, called unsafe superpowers, that you can’t in safe Rust. Those superpowers include the ability to:</em></blockquote><blockquote><em>Dereference a raw pointer</em></blockquote><blockquote><em>Call an unsafe function or method</em></blockquote><blockquote><em>Access or modify a mutable static variable</em></blockquote><blockquote><em>Implement an unsafe trait</em></blockquote><blockquote><em>Access fields of unions</em></blockquote><blockquote><em>Calling unsafe() would crash the program.</em></blockquote><blockquote><em>consider unsafe to be a warning sign rather than an indicator that you’re embarking on anything illegal. Unsafe means “the same level of safety offered by C at all times.”</em></blockquote><blockquote><em>If you still had access to (via unsafe) they might still look like valid S, but any attempt to use them as valid S is undefined behavior. ↓ </em><a href="https://cheats.rs/#unsafe-unsound-undefined-dark"><em>https://cheats.rs/#unsafe-unsound-undefined-dark</em></a><em> side of force Try to avoid “unsafe {}”, often safer, faster solution without it. Exception: FFI. People are fallible, and mistakes will happen, but by requiring these five unsafe operations to be inside blocks annotated with unsafe you’ll know that any errors related to memory safety must be within an unsafe block. Keep unsafe blocks small; you’ll be thankful later when you investigate memory bugs. To isolate unsafe code as much as possible, it’s best to enclose unsafe code within a safe abstraction and provide a safe API, which we’ll discuss later in the chapter when we examine unsafe functions and methods.</em></blockquote><blockquote><em>Parts of the standard library are implemented as safe abstractions over unsafe code that has been audited. Wrapping unsafe code in a safe abstraction prevents uses of unsafe from leaking out into all the places that you or your users might want to use the functionality implemented with unsafe code, because using a safe abstraction is safe.</em></blockquote><h3>Contributors<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#contributors">¶</a></h3><p>nom is the fruit of the work of many contributors over the years, many thanks for your help!</p><p><a href="https://github.com/armanriazi/rust-scratch-blockchain/graphs/contributors">Contributors</a></p><h3>Welcome To The Home Blockchain Of 🦀Rustaceans<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#welcome-to-the-home-blockchain-of-rustaceans_1">¶</a></h3><blockquote><em>The repo is a </em><strong><em>prerequisite of the Substrate-Framework</em></strong><em> and it would be nicer to practice too.</em></blockquote><blockquote><em>The repo is included Rust syntax, configuration and the goal of creating scratch codes like one is becuase of providing </em><strong><em>testbed environment of Blockchain</em></strong><em>.</em></blockquote><blockquote><em>The Next reason is to using some </em><strong><em>features of Rust-Lang</em></strong><em> that I had wanted to implement it after learning Rust.</em></blockquote><blockquote><em>Used json in the main runner of the project so that consume </em><strong><em>json</em></strong><em> transactions as a </em><strong><em>offchain</em></strong><em> blockchain.</em></blockquote><blockquote><em>As you follow materials you can see (future work) which means you can add these concepts to the project. I have some </em><strong><em>idea</em></strong><em> that you can affort on it to completing future works.</em></blockquote><blockquote>Smart Contracts, MultiSignature, RPC, Make A Better CLI, and something that you can implementing<em> (Do not worry sice most of your works will merge to main branch. We will not create a framework or complete Blockchain because we just need to </em><strong><em>learning</em></strong><em> more and used it use-cases)</em></blockquote><h3>The difference between the current work and the prev works<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#the-difference-between-the-current-work-and-the-prev-works_1">¶</a></h3><blockquote><em>I have tried to use fundamental concepts correctly, for example, all of us know any block have not any copy so because of it we are calling blockchain! Unlike many repositories on GitHub(testbed/scratched projects-non productive) that almost use Copy/Clone attributes of Rust-Lang for creating block. In the following, there are some features that cause a different project.</em></blockquote><blockquote><em>Currently Status: Under refactoring with contributors</em></blockquote><h3>How To Contribute <a href="https://github.com/armanriazi/armanriazi/blob/main/HowToContribute.md">Easy</a><a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#how-to-contribute-easy_1">¶</a></h3><p><a href="https://armanriazi.github.io/site/public/programming/rust/rust/">[Rust 2021 A Scratch Blockchain-1]</a> <a href="https://youtu.be/hiYHzmqn6MY">Youtube-Rust 2021 A Scratch Blockchain-1</a></p><p><a href="https://armanriazi.github.io/site/public/programming/rust/rust/">Rust 2021 A Scratch Blockchain-2</a> <a href="https://youtu.be/gK0dFhtbB-M">Youtube-Rust 2021 A Scratch Blockchain-2</a></p><h3>Documents Crate<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#documents-crate">¶</a></h3><p><a href="https://docs.rs/crate/blockchain-scratch-rust/latest">Docs.rs</a></p><p><a href="https://crates.io/search?q=blockchain-scratch-rust">Package Manager crates.io</a></p><h3>Features<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#features_1">¶</a></h3><ul><li>[✓] Modular</li><li>[✓] Customized Error Handling</li><li>[✓] Json &amp; String Data Deserialized</li><li>[✓] Functional Programming(Closure)</li><li>[✓] Cryptography-Hashing Alogrithm SHA-256</li><li>[-] WebAssembly(Next future video)</li><li>[-] Unit &amp; Integration Testing(structure-need more time in the future)</li><li>[-] Configuration Files(devOps-need more time in the future)</li></ul><h3>Instructions for working with<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#instructions-for-working-with_1">¶</a></h3><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;DIFFICULTY={difficulty} cargo {mode} {file name}</pre><blockquote><em>{difficulty}: (optional-key-env) value default 0x00ffffffffffffffffffffffffffffff.It must be 32 byte.</em></blockquote><blockquote><em>{mode}: macro, string, file/ default mode is on the macrojson mode.</em></blockquote><blockquote><em>{macro, string} there is in project and you can not access or manipulate except by getting the project. serde_json support string and macro based on called library. {file} json file is external .json file that you can set it for command line</em></blockquote><blockquote><em>{file name} index directory of the project sample-bolocks.json</em></blockquote><blockquote><em>Example:</em></blockquote><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;cargo build<br>cargo run<br>RUST_LOG=INFO DIFFICULTY=0x00000fffffffffffffffffffffffffff time cargo run file sample-bolocks.json<br>DIFFICULTY=0x00000fffffffffffffffffffffffffff time cargo run macrojson<br>DIFFICULTY=0x00000fffffffffffffffffffffffffff time cargo run stringjson<br>time cargo run<br>cargo watch -x run<br>cargo test</pre><p><em>Using time and watch is optional and depends on your purpose</em></p><h3>Instructions for installing-bin<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#instructions-for-installing-bin">¶</a></h3><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;curl -LSfs https://github.com/armanriazi/armanriazi/blob/main/install-0.sh | sh -s -- --git armanriazi/rust-scratch-blockchain</pre><h3>How to consume the library<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#how-to-consume-the-library">¶</a></h3><p>1.</p><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;cargo new yourprojectname</pre><p>2. Add new dependency</p><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;[dependencies]<br>blockchain-scratch-rust = &quot;0.3.0&quot;</pre><p>3. To update dependencies</p><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;cargo update</pre><p>4. Your main.rs of the program</p><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;use library_blockchain::*;<br>fn main() {<br>    println!(&quot;Hello, world!&quot;);</pre><pre>    library_blockchain::blockchain_executive::main();<br>}</pre><p>5. Due to the file sample-three-block-noerror.json in the repo you might copy it and manipulate it, in spite of that you can use generators of your database or ORMs for producing a file.json as the same as following content. Get attention to keys in the file for example we must have transaction{number} and if we write ‘mytransaction 1’ and run it we will get error.</p><p><em>Json File</em></p><ol><li>Run of one of above commands.</li></ol><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;RUST_LOG=info DIFFICULTY=0x0000ffffffffffffffffffffffffffff time cargo run file sample-three-block-noerror.json</pre><p>7. Everything is Ok and it is working fine.<br><em>Console Log</em></p><h3>WASM(future work)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#wasmfuture-work">¶</a></h3><p>For consume the library we used some WASM compiling strategy:</p><blockquote><a href="https://github.com/armanriazi/rust-scratch-blockchain-bin/tree/armanriazi-bindgen0"><em>Bindgen</em></a></blockquote><blockquote><a href="https://github.com/armanriazi/rust-scratch-blockchain-bin/tree/armanriazi-wasmer-llvm"><em>Wasmer-LLVM</em></a></blockquote><blockquote><a href="https://github.com/armanriazi/rust-scratch-blockchain-bin/tree/armanriazi-wasmer-wasi"><em>Wasmer-Wasi</em></a></blockquote><blockquote><a href="https://github.com/armanriazi/rust-scratch-blockchain-bin"><em>Binary of rust-scratch-blockchain</em></a></blockquote><h3>Used Concepts<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#used-concepts_1">¶</a></h3><h4>- [✓] Memoization•Lazy•Evaluation<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-memoizationlazyevaluation_1">¶</a></h4><blockquote><em>We can create a struct that will hold the closure and the resulting value of calling the closure.</em></blockquote><blockquote><em>The struct will execute the closure only if we need the resulting value, and it will cache the resulting value so the rest of our code doesn’t have to be responsible for saving and reusing the result.</em></blockquote><blockquote><em>FnOnce consumes the variables it captures from its enclosing scope, known as the closure’s environment. To consume the captured variables, the closure must take ownership of these variables and move them into the closure when it is defined. The Once part of the name represents the fact that the closure can’t take ownership of the same variables more than once, so it can be called only once.</em></blockquote><blockquote><em>FnMut can change the environment because it mutably borrows values.</em></blockquote><blockquote><em>Fn borrows values from the environment immutably. FnOnce: takes the whole value. FnMut: takes a mutable reference. Fn: takes a regular reference.</em></blockquote><h4>- [✓] Coercion<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-coercion_1">¶</a></h4><blockquote><em>Deref coercion is a convenience that Rust performs on arguments to functions and methods. Deref coercion works only on types that implement the Deref trait. Deref coercion converts such a type into a reference to another type. For example, deref coercion can convert &amp;String to &amp;str because String implements the Deref trait such that it returns &amp;str.</em></blockquote><blockquote><em>The number of times that Deref::deref needs to be inserted is resolved at compile time, so there is no runtime penalty for taking advantage of deref coercion! Similar to how you use the Deref trait to override the * operator on immutable references, you can use the DerefMut trait to override the * operator on mutable references.the Drop trait is almost always used when implementing a smart pointer. For example, when a Box is dropped it will deallocate the space on the heap that the box points to.</em></blockquote><blockquote><em>Note that we didn’t need to call the drop method explicitly.</em></blockquote><h4>- [✓] DST•Or•Unsizedtype<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-dstorunsizedtype_1">¶</a></h4><blockquote><em>DSTs or unsized types’: str(but not &amp;str-So although a &amp;T is a single value that stores the memory address of where the T is located, a &amp;str is two values: the address of the str and its length. Rust has a particular trait called the Sized trait to determine whether or not a type’s size is known at compile time. This trait is automatically implemented for everything whose size is known at compile time. In addition, Rust implicitly adds a bound on Sized to every generic function.</em></blockquote><h4>- [✓] Operation<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-operation_1">¶</a></h4><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;-&gt; Methods are functions that are coupled to some object.</pre><blockquote><em>From a syntactic point of view, these are just functions that don’t need to specify one of their arguments. Rather than calling open() and passing a File object in as an argument (read(f, buffer)), methods allow the main object to be implicit in the function call (f.read(buffer)) using the dot operator.</em></blockquote><blockquote><em>There are a number of theoretical differences between methods and functions, but a detailed discussion of those computer science topics is available in other books. Briefly, functions are regarded as pure, meaning their behavior is determined solely by their arguments. Methods are inherently impure, given that one of their arguments is effectively a side effect. These are muddy waters, though. Functions are perfectly capable of acting on side effects themselves. Moreover, methods are implemented with functions. And, to add an exception to an exception, objects sometimes implement static methods, which do not include implicit arguments. To define methods, Rust programmers use an impl block</em></blockquote><h4>- [✓] Borrowchecker<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-borrowchecker_1">¶</a></h4><blockquote><em>The borrow checker checks that all access to data is legal, which allows Rust to prevent safety issues. Learning how this works will, at the very least, speed up your development time by helping you avoid run-ins with the compiler. More significantly though, learning to work with the borrow checker allows you to build larger software systems with confidence. It underpins the term fearless concurrency.</em></blockquote><h4>- [✓] Borrowchecker•Lifetime<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-borrowcheckerlifetime_1">¶</a></h4><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;-&gt; Lifetime=Timetolive=Subset of their scope</pre><blockquote><em>Make hypotheses about whether or not your experiments will pass the borrow checker before you compile reference in Rust has a lifetime, which is the scope for which that reference is valid. Most of the time, lifetimes are implicit and inferred, just like most of the time, types are inferred. We must annotate types when multiple types are possible. In a similar way, we must annotate lifetimes when the lifetimes of references could be related in a few different ways.</em></blockquote><blockquote><em>The main aim of lifetimes is to prevent dangling references, which cause a program to reference data other than the data it’s intended to reference. All references in Rust have a lifetime, even if they are not explicitly annotated. The compiler is capable of implicitly assigning lifetimes.</em></blockquote><blockquote><em>A value’s lifetime is the period when accessing that value is valid behavior. A function’s local variables live until the function returns, while global variables might live for the life of the program.</em></blockquote><blockquote><em>The notion of ownership is rather limited. An owner cleans up when its values’ lifetimes end.</em></blockquote><blockquote><em>Although every parameter has a lifetime, these checks are typically invisible as the compiler can infer most lifetimes by itself.</em></blockquote><blockquote><em>All values bound to a given lifetime must live as long as the last access to any value bound to that lifetime.</em></blockquote><blockquote><em>No lifetime annotations are required when calling a function.</em></blockquote><blockquote><em>Lifetime annotations don’t change how long any of the references live. Just as functions can accept any type when the signature specifies a generic type parameter, functions can accept references with any lifetime by specifying a generic lifetime parameter.</em></blockquote><blockquote><em>Lifetime annotations describe the relationships of the lifetimes of multiple references to each other without affecting the lifetimes.</em></blockquote><blockquote><em>The lifetime annotations indicate that the references first and second must both live as long as that generic lifetime.</em></blockquote><blockquote><em>Lifetimes on function or method parameters are called input lifetimes, and lifetimes on return values are called output lifetimes.</em></blockquote><blockquote><em>Although every parameter has a lifetime, these checks are typically invisible as the compiler can infer most lifetimes by itself</em></blockquote><blockquote><em>All values bound to a given lifetime must live as long as the last access to any value bound to that lifetime.</em></blockquote><blockquote><em>No lifetime annotations are required when calling a function.</em></blockquote><blockquote><em>Using two lifetime parameters (a and b) indicates that the lifetimes of i and j are decoupled.</em></blockquote><blockquote><em>fn add_with_lifetimes&lt;’a, ‘b&gt;(i: &amp;’a i32, j: &amp;’b i32) -&gt; i32 {}</em></blockquote><blockquote><em>Lifetime of that usage:</em></blockquote><blockquote><em>the LOC(‘existence time’ or Line of code) between when a location is first used in a certain way, and when that usage stops.</em></blockquote><blockquote><em>Lifetime of that value:</em></blockquote><blockquote><em>the LOC (or actual time) between when a value is created, and when that value is dropped.</em></blockquote><blockquote><em>Might be useful when discussing open file descriptors, but also irrelevant here.</em></blockquote><blockquote><em>Ultimately, lifetime syntax is about connecting the lifetimes of various parameters and return values of functions. Once they’re connected, Rust has enough information to allow memory-safe operations and disallow operations that would create dangling pointers or otherwise violate memory safety.</em></blockquote><h4>- [✓] Dangle<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-dangle_1">¶</a></h4><blockquote><em>The main aim of lifetimes is to prevent dangling references.which has an outer scope and an inner scope. In return section of a function primitive types need to define as (&amp;’a or &amp;’static)</em></blockquote><h4>- [✓] Generic<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-generic_1">¶</a></h4><blockquote><em>You might be wondering whether there is a runtime cost when using generic type parameters. The good news is that using generic types won’t make your run any slower than it would with concrete types.</em></blockquote><blockquote><em>Rust accomplishes this by performing monomorphization of the code using generics at compile time. Monomorphization is the process of turning generic code into specific code by filling in the concrete types that are used when compile. Every programming language has tools for effectively handling the duplication of concepts.</em></blockquote><blockquote><em>In Rust, one such tool is generics. Generics are abstract stand-ins for concrete types or other properties. When we’re writing code, we can express the behavior of generics or how they relate to other generics without knowing what will be in their place when compiling and running the code.</em></blockquote><h4>Static•Dispatch(Passed)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#staticdispatchpassed_1">¶</a></h4><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;-&gt; Monomorphization</pre><blockquote><em>Dispatch is the mechanism to determine which specific version of code is actually run when it involves polymorphism. Two major forms of dispatch are static dispatch and dynamic dispatch. While Rust favors static dispatch, it also supports dynamic dispatch through a mechanism called ‘trait objects’. When Rust compiles this code, it performs monomorphization.</em></blockquote><blockquote><em>The monomorphized version of the code looks like the following. The generic Option is replaced with the specific definitions created by the compiler: versions of a polymorphic function (or any polymorphic entity) during compilation is called Monomorphization.</em></blockquote><blockquote><em>Because Rust compiles generic code into code that specifies the type in each instance, we pay no runtime cost for using generics. When the code runs, it performs just as it would if we had duplicated each definition by hand. The process of monomorphization makes Rust’s generics extremely efficient at runtime. This is opposed to dynamic dispatch</em></blockquote><h4>- [✓] Dynamic•Dispatch<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-dynamicdispatch_1">¶</a></h4><blockquote><em>The code that results from monomorphization is doing static dispatch, which is when the compiler knows what method you’re calling at compile time. This is opposed to dynamic dispatch, which is when the compiler can’t tell at compile time which method you’re calling. In dynamic dispatch cases, the compiler emits code that at runtime will figure out which method to call.</em></blockquote><blockquote><em>When we use trait objects, Rust must use dynamic dispatch. The compiler doesn’t know all the types that might be used with the code that is using trait objects, so it doesn’t know which method implemented on which type to call. Instead, at runtime, Rust uses the pointers inside the trait object to know which method to call. There is a runtime cost when this lookup happens that doesn’t occur with static dispatch. Dynamic dispatch also prevents the compiler from choosing to inline a method’s code, which in turn prevents some optimizations.</em></blockquote><h4>- [-] Blanket•Implementation<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-blanketimplementation_1">¶</a></h4><blockquote><em>Any implementation where a type appears uncovered. impl Foo for T, impl Bar for T, impl Bar&gt; for T, and impl Bar for Vec are considered blanket impls.</em></blockquote><blockquote><em>We can also conditionally implement a trait for any type that implements another trait. Implementations of a trait on any type that satisfies the trait bounds are called blanket implementations and are extensively used in the Rust standard library. For example, the standard library implements the ToString trait on any type that implements the Display trait.</em></blockquote><h4>- [✓] Bound(syntax)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-boundsyntax_1">¶</a></h4><blockquote><em>Bounds are constraints on a type or trait. For example, if a bound is placed on the argument a function takes, types passed to that function must abide by that constraint.</em></blockquote><h4>- [✓] Trait<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-trait_1">¶</a></h4><blockquote><em>We can use traits to define shared behavior in an abstract way. We can use trait bounds to specify that a generic type can be any type that has certain behavior. Traits are similar to a feature often called interfaces in other languages, although with some differences.</em></blockquote><blockquote><em>What is a trait? A trait is a language feature that is analogous to an interface, protocol, or contract. If you have a background in object-oriented programming, consider a trait to be an abstract base class. If you have a background in functional programming, Rust’s traits are close to Haskell’s type classes these also support a form of inheritance that’s common in most object oriented languages. For now, though, the thing to remember is that traits represent common behavior (Or reusable codes like println!)that types opt into via the syntax impl Trait for Type.</em></blockquote><blockquote><em>After the method signature, instead of providing an implementation within curly brackets, we use a semicolon.</em></blockquote><blockquote><em>This interface consists of associated items, which come in three varieties: functions, types, constants.</em></blockquote><blockquote><em>All traits define an implicit type parameter Self that refers to “the type that is implementing this interface”.</em></blockquote><blockquote><em>Trait functions may omit the function body by replacing it with a semicolon. This indicates that the implementation must define the function. If the trait function defines a body, this definition acts as a default for any implementation which does not override it. Similarly, associated constants may omit the equals sign and expression to indicate implementations must define the constant value. Associated types must never define the type, the type may only be specified in an implementation.</em></blockquote><h4>- [✓] Polymorphism<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-polymorphism_1">¶</a></h4><blockquote><em>In a struct or enum, the data in the struct fields and the behavior in impl blocks are separated, whereas in other languages, the data and behavior combined into one concept is often labeled an object.However, trait objects are more like objects in other languages in the sense that they combine data and behavior.</em></blockquote><h4>- [✓] Unrolling<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-unrolling_1">¶</a></h4><blockquote><em>It is an optimization that removes the overhead of the loop controlling code and instead generates repetitive code for each iteration of the loop.</em></blockquote><h4>- [✓] Binding•Match<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-bindingmatch_1">¶</a></h4><blockquote><em>The compiler automatically references the Some, and since we’re borrowing, name is bound as ref name automatically as well. If we were mutating:</em></blockquote><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt; //https://blog.rust-lang.org/2018/05/10/Rust-1.26.html#nicer-match-bindings<br>// `self` has type `&amp;List`, and `*self` has type `List`, matching on a<br>// concrete type `T` is preferred over a match on a reference `&amp;T`<br>// after Rust 2018 you can use self here and tail (with no ref) below as well,<br>// rust will infer &amp;s and ref tail.</pre><h4>- [✗] Datarace•Rustaceans<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-dataracerustaceans_1">¶</a></h4><blockquote><em>Note: The opposite of referencing by using &amp; is dereferencing, which is accomplished with the dereference operator, *.</em></blockquote><h4>[-] Nan(philosophy)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-nanphilosophy_1">¶</a></h4><blockquote><em>Floating-point types include “not a number” values (represented in Rust syntax as NAN values) to handle these cases.</em></blockquote><blockquote><em>NAN values poison other numbers. Almost all operations interacting with NAN return NAN. Another thing to be mindful of is that, by definition, NAN values are never equal. Programming language design is often thought of in terms of which features you include, but the features you exclude are important too. Rust doesn’t have the null feature that many other languages have. Null is a value that means there is no value there. In languages with null, variables can always be in one of two states: null or not-null. In his 2009 presentation “Null References: The Billion Dollar Mistake,” Tony Hoare, the inventor of null, has this to say: I call it my billion-dollar mistake. At that time, I was designing the first comprehensive type system for references in an object-oriented language. My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn’t resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years.</em></blockquote><blockquote><em>To program defensively, make use of the is_nan() and is_finite() methods. Inducing a crash, rather than silently proceeding with a mathematical error, allows you to debug close to what has caused the problem. The following illustrates using the is_finite()</em></blockquote><h4>- [✓] Duplication((literal)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-duplicationliteral_1">¶</a></h4><blockquote><em>Concept of copying the pointer, length, and capacity without copying the data probably sounds like making a shallow copy.</em></blockquote><blockquote><em>If we do want to deeply copy the heap data of the String, not just the stack data, we can use a common method called clone</em></blockquote><h4>- [✓] Semantic(literal)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-semanticliteral_1">¶</a></h4><blockquote><em>Primitive types are said to possess copy semantics, whereas all other types have move semantics. Adding more functionality (e.g., reference-counting semantics rather than move semantics) to types by wrapping these in other types typically reduces their run-time performance.</em></blockquote><h4>- [✓] Zero•Cost•Abstractions(literal)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-zerocostabstractionsliteral_1">¶</a></h4><blockquote><em>One of the ways this manifests is by not adding extra data around values within structs.</em></blockquote><h4>- [✓] Coherence(literal)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-coherenceliteral_1">¶</a></h4><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;-&gt; Orphan = Trait•External•Implement</pre><blockquote><em>But we can’t implement external traits on external types. For example, we can’t implement the Display trait on Vec within our aggregator crate, because Display and Vec are defined in the standard library and aren’t local to our aggregator crate. This restriction is part of a property of programs called coherence, and more specifically the orphan rule, so named because the parent type is not present. This rule ensures that other people’s code can’t break your code and vice versa.</em></blockquote><blockquote><em>Without the rule, two crates could implement the same trait for the same type, and Rust wouldn’t know which implementation to use.</em></blockquote><blockquote><em>Preserves contextual coherence of trace data from tasks/function/methods when logging.</em></blockquote><blockquote><em>For example new instance of a struct of course, as you probably already know, struct then you can just summerize your struct in a method.</em></blockquote><h4>- [✓] Jargon(literal)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-jargonliteral_1">¶</a></h4><blockquote><em>Functional programming jargon: “to cons x onto y” informally means to construct a new container instance by putting the element x at the start of this new container, followed by the container y.Other, more complex recursive data types are useful in various situations, but by starting with the cons list, we can explore how boxes let us define a recursive data type without much distraction.</em></blockquote><h4>- [✓] Refactor(literal)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-refactorliteral_1">¶</a></h4><blockquote><em>One alternative to refactoring is to simply copy values. Doing this often is typically frowned upon, however, but it can be useful in a pinch. Primitive types like integers are a good example of that. Primitive types are cheap for a CPU to duplicate — so cheap, in fact, that Rust always copies these if it would otherwise worry about ownership being moved.</em></blockquote><blockquote><em>Types can opt into two modes of duplication: cloning and copying.</em></blockquote><h4>- [✓] Pattern•Newtype<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-patternnewtype_1">¶</a></h4><blockquote><em>Using the Newtype Pattern to Implement External Traits on External Types ‘thin wrapper around the type’ : part of Vec is noticed. We can make a Wrapper struct that holds an instance of Vec; then we can implement Display on Wrapper and use the Vec value The downside of using this technique is that Wrapper is a new type, so it doesn’t have the methods of the value it’s holding. We would have to implement all the methods of Vec directly on Wrapper such that the methods delegate to self.0, which would allow us to treat Wrapper exactly like a Vec.</em></blockquote><blockquote><em>If we wanted the new type to have every method the inner type has, implementing the Deref trait (If we don’t want the Wrapper type to have all the methods of the inner type — for example, to restrict the Wrapper type’s behavior — we would have to implement just the methods we do want manually.)</em></blockquote><h4>- [✗] Pattern•Design•Interior(future work)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-patterndesigninteriorfuture-work_1">¶</a></h4><blockquote><em>Interior mutability is a design pattern in Rust that allows you to mutate data even when there are immutable references to that data; normally, this action is disallowed by the borrowing rules. To mutate data, the pattern uses unsafe code inside a data structure to bend Rust’s usual rules that govern mutation and borrowing.</em></blockquote><blockquote><em>RefCell type that follows the interior mutability pattern.</em></blockquote><blockquote><em>Unlike Rc, the RefCell type represents single ownership over the data it holds. So, what makes RefCell different from a type like Box? Recall the borrowing rules…</em></blockquote><blockquote><em>Similar to Rc, RefCell is only for use in single-threaded scenarios and will give you a compile-time error if you try using it in a multithreaded context. At any given time, you can have either (but not both of) one mutable reference or any number of immutable references.References must always be valid.</em></blockquote><h4>- [✗] Type•Wraper(future work)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-typewraperfuture-work_1">¶</a></h4><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;-&gt; Wrapper type = Reference-Counted Value = Shared Ownership = Track valid references</pre><blockquote><em>Use wrapper types, which allow more flexibility than what is available by default. These, however, incur costs at runtime to ensure that Rust’s safety guarantees are maintained. Another way to phrase this is that Rust allows programmers to opt in to garbage collection.</em></blockquote><h4>- [✗] Mem•Leak(future work)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-memleakfuture-work_1">¶</a></h4><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;-&gt; Managing Memory Leak</pre><blockquote><em>Rust’s memory safety guarantees make it difficult, but not impossible, to accidentally create memory that is never cleaned up (known as a memory leak). Preventing memory leaks entirely is not one of Rust’s guarantees in the same way that disallowing data races at compile time is, meaning memory leaks are memory safe in Rust.</em></blockquote><blockquote><em>We can see that Rust allows memory leaks by using Rc and RefCell: it’s possible to create references where items refer to each other in a cycle. This creates memory leaks because the reference count of each item in the cycle will never reach 0, and the values will never be dropped.</em></blockquote><p>- [✗] MEM•DOUBLEFREE(FUTURE WORK)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-memdoublefreefuture-work_1">¶</a></p><blockquote><em>This is a problem: when s2 and s1 (s2 is copied s1 means 2different pointer and the same data) go out of scope, they will both try to free the same memory. This is known as a double free error and is one of the memory safety bugs we mentioned previously. Freeing memory twice can lead to memory corruption, which can potentially lead to security vulnerabilities.</em></blockquote><h4>- [✗] Mem•Deallocating•or•RAII(future work)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-memdeallocatingorraiifuture-work_1">¶</a></h4><blockquote><em>Note: In C++, this pattern of deallocating resources at the end of an item’s lifetime is sometimes called Resource Acquisition Is Initialization (RAII). The drop function in Rust will be familiar to you if you’ve used RAII patterns.</em></blockquote><h4>- [✗] Thread(future work)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-threadfuture-work_1">¶</a></h4><blockquote><em>Which parts of your code on different threads will run. This can lead to problems, such as:</em></blockquote><blockquote><em>Race conditions, where threads are accessing data or resources in an inconsistent order Deadlocks, where two threads are waiting for each other to finish using a resource the other thread has, preventing both threads from continuing Bugs that happen only in certain situations and are hard to reproduce and fix reliably.</em></blockquote><h4>- [✗] Thread•Strateges(future work)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-threadstrategesfuture-work_1">¶</a></h4><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;-&gt; Priority Performance</pre><blockquote><em>Stealing_Join: execute code in parallel when there are idle CPUs to handle it.</em></blockquote><blockquote><em>When join is called from outside the thread pool, the calling thread will block while the closures execute in the pool. When join is called within the pool, the calling thread still actively participates in the thread pool. It will begin by executing closure A (on the current thread). While it is doing that, it will advertise closure B as being available for other threads to execute. Once closure A has completed, the current thread will try to execute closure B; if however closure B has been stolen, then it will look for other work while waiting for the thief to fully execute closure B. (This is the typical work-stealing strategy). Send is require because we have jump from quick func(thread a) to part func(thread b) frequently.</em></blockquote><blockquote><em>Atomic: types provide primitive shared-memory communication between threads, and are the building blocks of other concurrent types. This module defines atomic versions of a select number of primitive types, including AtomicBool, AtomicIsize, AtomicUsize, AtomicI8, AtomicU16, etc. Atomic types present operations that, when used correctly, synchronize updates between threads. Each method takes an Ordering which represents the strength of the memory barrier for that operation. These orderings are the same as the C++20 atomic orderings. For more information see the nomicon.</em></blockquote><blockquote><em>Atomic variables are safe to share between threads (they implement Sync) but they do not themselves provide the mechanism for sharing and follow the threading model of Rust. The most common way to share an atomic variable is to put it into an Arc (an atomically-reference-counted shared pointer). Atomic types may be stored in static variables, initialized using the constant initializers like AtomicBool::new. Atomic statics are often used for lazy global initialization.</em></blockquote><blockquote><em>Spin_Loop_Yeild also known as busy loop and spin loop-If you want to sleep pause a thread for short amounts of time, or if your application is sensitive to timing, use a spin loop</em></blockquote><h4>- [✗] Unsafe•Extern•Mangling(future work)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-unsafeexternmanglingfuture-work_1">¶</a></h4><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;&gt; Mangling is when a compiler changes the name we’ve given a function to a different name that contains more information for other parts of the compilation process to consume but is less human readable. Every programming language compiler mangles names slightly differently, so for a Rust function to be nameable by other languages, we must disable the Rust compiler’s name mangling.</pre><h4>- [✓] Interior•Mutability•Pattern<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-interiormutabilitypattern_1">¶</a></h4><p>RefCell: Lets us have many immutable borrows or one mutable borrow at any point in time. Mutating the value inside an immutable value is the interior mutability pattern. Interior mutability is a design pattern in Rust that allows you to mutate data even when there are immutable references to that data; normally, this action is disallowed by the borrowing rules. To mutate data, the pattern uses unsafe code inside a data structure to bend Rust’s usual rules that govern mutation and borrowing. RefCell type that follows the interior mutability pattern. Unlike Rc, the RefCell type represents single ownership over the data it holds. So, what makes RefCell different from a type like Box? Recall the borrowing rules, Similar to Rc, RefCell is only for use in single-threaded scenarios and will give you a compile-time error if you try using it in a multithreaded context. At any given time, you can have either (but not both of) one mutable reference or any number of immutable references.References must always be valid.</p><h4>- [✗] OOP•State•DesignPattern(future work)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-oopstatedesignpatternfuture-work_1">¶</a></h4><pre>code&quot; style=&quot;box-sizing: inherit; transition: color 0.25s ease 0s; -webkit-tap-highlight-color: transparent; background: transparent; border: 0px; font-family: inherit; font-size: inherit; margin: 0px; padding: 0px; border-radius: 0.1rem; color: var(--md-default-fg-color--lightest); cursor: pointer; height: 1.5em; outline: none; outline-offset: 0.1rem; position: absolute; right: 0.5em; top: 0.5em; width: 1.5em; z-index: 1;&quot;&gt;-&gt; We can used it for smart contracts so we will need to implemented smart contracts</pre><blockquote><em>Using the state pattern means when the business requirements of the program change, we won’t need to change the code of the value holding the state or the code that uses the value. We’ll only need to update the code inside one of the state objects to change its rules or perhaps add more state objects.</em></blockquote><blockquote><em>e.g Post type. This type will use the state pattern and will hold a value that will be one of three state objects representing the various states a post can be in — draft, waiting for review, or published. Changing from one state to another will be managed internally within the Post type. The states change in response to the methods called by our library’s users on the Post instance, but they don’t have to manage the state changes directly. Also, users can’t make a mistake with the states, like publishing a post before it’s reviewed.</em></blockquote><h4>- [✗] Superpower(future work)<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#-superpowerfuture-work_1">¶</a></h4><blockquote><em>if the Rust compiler doesn’t have enough information to be confident, it will reject the code. In these cases, you can use unsafe code to tell the compiler, “Trust me, I know what I’m doing.” The downside is that you use it at your own risk: if you use unsafe code incorrectly, problems due to memory unsafety, such as null pointer dereferencing, can occur.</em></blockquote><blockquote><em>You can take five actions in unsafe Rust, called unsafe superpowers, that you can’t in safe Rust. Those superpowers include the ability to:</em></blockquote><blockquote><em>Dereference a raw pointer</em></blockquote><blockquote><em>Call an unsafe function or method</em></blockquote><blockquote><em>Access or modify a mutable static variable</em></blockquote><blockquote><em>Implement an unsafe trait</em></blockquote><blockquote><em>Access fields of unions</em></blockquote><blockquote><em>Calling unsafe() would crash the program.</em></blockquote><blockquote><em>consider unsafe to be a warning sign rather than an indicator that you’re embarking on anything illegal. Unsafe means “the same level of safety offered by C at all times.”</em></blockquote><blockquote><em>If you still had access to (via unsafe) they might still look like valid S, but any attempt to use them as valid S is undefined behavior. ↓ </em><a href="https://cheats.rs/#unsafe-unsound-undefined-dark"><em>https://cheats.rs/#unsafe-unsound-undefined-dark</em></a><em> side of force Try to avoid “unsafe {}”, often safer, faster solution without it. Exception: FFI. People are fallible, and mistakes will happen, but by requiring these five unsafe operations to be inside blocks annotated with unsafe you’ll know that any errors related to memory safety must be within an unsafe block. Keep unsafe blocks small; you’ll be thankful later when you investigate memory bugs. To isolate unsafe code as much as possible, it’s best to enclose unsafe code within a safe abstraction and provide a safe API, which we’ll discuss later in the chapter when we examine unsafe functions and methods.</em></blockquote><blockquote><em>Parts of the standard library are implemented as safe abstractions over unsafe code that has been audited. Wrapping unsafe code in a safe abstraction prevents uses of unsafe from leaking out into all the places that you or your users might want to use the functionality implemented with unsafe code, because using a safe abstraction is safe.</em></blockquote><h3>Contributors<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#contributors_1">¶</a></h3><p>nom is the fruit of the work of many contributors over the years, many thanks for your help!</p><p><a href="https://github.com/armanriazi/rust-scratch-blockchain/graphs/contributors">Contributors</a></p><h3>Thanks<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#thanks">¶</a></h3><p><a href="https://users.rust-lang.org/u/LegionMammal978">Convert string to u128</a></p><h3>Solved Issues<a href="https://armanriazi.github.io/site/public/programming/rust/rust-scratch-blockchain/#solved-issues">¶</a></h3><p><a href="https://users.rust-lang.org/t/convert-string-to-u128/77183">Convert-string-to-u128</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12c2d649e63d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>