<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/lessons-learned-building-an-extended-standard-library-for-rust-stdx--edvlhvu6t" -->

---
title: Lessons learned building an extended standard library...
description: An extended Rust standard library project called stdx aims to address Rust's fragmented ecosystem and supply chain security issues. The author shares design...
canonical: https://daily.dev/posts/lessons-learned-building-an-extended-standard-library-for-rust-stdx--edvlhvu6t
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Lessons learned building an extended standard library for Rust (stdx) | daily.dev
og:description: An extended Rust standard library project called stdx aims to address Rust's fragmented ecosystem and supply chain security issues. The author shares design...
og:url: https://daily.dev/posts/lessons-learned-building-an-extended-standard-library-for-rust-stdx--edvlhvu6t
og:image: https://api.daily.dev/og/posts/edvLHvu6t.png
og:image:alt: Lessons learned building an extended standard library for Rust (stdx)
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Lessons learned building an extended standard library for Rust (stdx)

**[Sylvain Kerkour](https://daily.dev/sources/kerkour)** · 3 min read · 2 upvotes · 1 comments

## Summary

An extended Rust standard library project called stdx aims to address Rust's fragmented ecosystem and supply chain security issues. The author shares design lessons for building libraries portable across microcontrollers (32 KB RAM) and large servers (1 TB RAM): avoiding heap allocations using smallvec's SmallVec type for stack-allocated collections with a fixed inline capacity, designing APIs with caller-provided buffers instead of returning allocated Vecs, and building runtime-agnostic sans-IO cores with wrappers for tokio and embassy async runtimes.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://kerkour.com/lessons-learned-building-stdx>

## Questions this post answers

### How does the smallvec crate avoid heap allocations in Rust?

The smallvec crate provides a SmallVec<T, N> type that behaves like a Vec<T> but is allocated inline, typically on the stack, for up to N elements. Choosing an appropriate N lets a data structure avoid heap allocation entirely on embedded systems with predictable input sizes while still falling back to heap allocation for larger, general-purpose use cases such as user-defined IDs on a server.

_Developers weighing allocation strategies for embedded versus server Rust code can find related deep dives through daily.dev._

### How can I design a Rust API that avoids heap allocations for encoding data?

Instead of returning a heap-allocated Vec<u8> from a function like fn encode(data: &[u8]) -> Result<Vec<u8>, Error>, design the API to accept a caller-provided buffer: fn encode(dst: &mut [u8], data: &[u8]) -> Result<(), Error>. This shifts allocation responsibility to the caller, letting embedded callers use stack buffers while server callers can still allocate as needed.

_Rust developers optimizing for both microcontrollers and servers can track patterns like this via daily.dev._

### What does it mean for a Rust library to be runtime-agnostic across tokio and embassy?

A runtime-agnostic Rust library is built around a sans-IO core with separate wrapper layers for each async runtime, such as tokio for mainstream server applications and embassy for embedded async use cases. This separation lets the core logic run identically regardless of runtime, covering roughly 99% of use cases without duplicating implementation.

_Anyone choosing an async runtime strategy for cross-platform Rust libraries can follow this space on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@agustinbarrientos** · 0 upvotes

> Very clear caller-owned buffer example, thanks

## Similar posts on daily.dev

- [Supply chain nightmare: How Rust will be attacked and what we can do to mitigate the inevitable](https://daily.dev/posts/supply-chain-nightmare-how-rust-will-be-attacked-and-what-we-can-do-to-mitigate-the-inevitable-xdchrtlnw) · Hacker News · 0 upvotes · 1 comments
- [Practical Rust API Design](https://daily.dev/posts/practical-rust-api-design-qwmqrnfyi) · corrode · 51 upvotes · 7 comments
- [What we heard about Rust's challenges, and how we can address them](https://daily.dev/posts/what-we-heard-about-rust-s-challenges-and-how-we-can-address-them-c6aca52fj) · Rust · 14 upvotes · 1 comments
- [Building scalable backend services with Rust and PostgreSQL](https://daily.dev/posts/building-scalable-backend-services-with-rust-and-postgresql-tlwj69w1v) · Sylvain Kerkour · 6 upvotes · 3 comments

---

Tags: [#security](https://daily.dev/tags/security), [#architecture](https://daily.dev/tags/architecture), [#rust](https://daily.dev/tags/rust), [#embedded](https://daily.dev/tags/embedded)

[View this post on daily.dev](https://daily.dev/posts/lessons-learned-building-an-extended-standard-library-for-rust-stdx--edvlhvu6t)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Lessons learned building an extended standard library for Rust (stdx)","url":"https://daily.dev/posts/lessons-learned-building-an-extended-standard-library-for-rust-stdx--edvlhvu6t","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/lessons-learned-building-an-extended-standard-library-for-rust-stdx--edvlhvu6t"},"datePublished":"2026-08-27T08:44:44.297Z","dateModified":"2026-10-29T02:14:09.293Z","description":"An extended Rust standard library project called stdx aims to address Rust's fragmented ecosystem and supply chain security issues. The author shares design...","image":"https://media.daily.dev/image/upload/s--qPvKM23u--/f_auto/v1722860399/public/Placeholder%2009","thumbnailUrl":"https://media.daily.dev/image/upload/s--qPvKM23u--/f_auto/v1722860399/public/Placeholder%2009","isAccessibleForFree":true,"articleSection":"Sylvain Kerkour","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Sylvain Kerkour","logo":"https://media.daily.dev/image/upload/s--3ngWt4Yp--/f_auto,q_auto/v1786438308/logos/kerkour?_a=BAMAMicg0","url":"https://daily.dev/sources/kerkour"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/lessons-learned-building-an-extended-standard-library-for-rust-stdx--edvlhvu6t","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"security,architecture,rust,embedded","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Sylvain Kerkour","item":"https://daily.dev/sources/kerkour"},{"@type":"ListItem","position":3,"name":"Lessons learned building an extended standard library for Rust (stdx)"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/lessons-learned-building-an-extended-standard-library-for-rust-stdx--edvlhvu6t","comment":[{"@type":"Comment","text":"Very clear caller-owned buffer example, thanks","datePublished":"2026-09-01T00:35:45.960Z","url":"https://daily.dev/posts/edvLHvu6t#c-05mF7VQf3","author":{"@type":"Person","name":"Agustin Barrientos","url":"https://daily.dev/agustinbarrientos","image":"https://media.daily.dev/image/upload/s--5ayxQnqn--/f_auto/v1788281802/avatars/avatar_wQYYVe5Tbj0NJ7C7qPoa8?_a=BAMAMicg0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/lessons-learned-building-an-extended-standard-library-for-rust-stdx--edvlhvu6t#faq","mainEntity":[{"@type":"Question","name":"How does the smallvec crate avoid heap allocations in Rust?","acceptedAnswer":{"@type":"Answer","text":"The smallvec crate provides a SmallVec\u003cT, N\u003e type that behaves like a Vec\u003cT\u003e but is allocated inline, typically on the stack, for up to N elements. Choosing an appropriate N lets a data structure avoid heap allocation entirely on embedded systems with predictable input sizes while still falling back to heap allocation for larger, general-purpose use cases such as user-defined IDs on a server. Developers weighing allocation strategies for embedded versus server Rust code can find related deep dives through daily.dev."}},{"@type":"Question","name":"How can I design a Rust API that avoids heap allocations for encoding data?","acceptedAnswer":{"@type":"Answer","text":"Instead of returning a heap-allocated Vec\u003cu8\u003e from a function like fn encode(data: \u0026[u8]) -\u003e Result\u003cVec\u003cu8\u003e, Error\u003e, design the API to accept a caller-provided buffer: fn encode(dst: \u0026mut [u8], data: \u0026[u8]) -\u003e Result\u003c(), Error\u003e. This shifts allocation responsibility to the caller, letting embedded callers use stack buffers while server callers can still allocate as needed. Rust developers optimizing for both microcontrollers and servers can track patterns like this via daily.dev."}},{"@type":"Question","name":"What does it mean for a Rust library to be runtime-agnostic across tokio and embassy?","acceptedAnswer":{"@type":"Answer","text":"A runtime-agnostic Rust library is built around a sans-IO core with separate wrapper layers for each async runtime, such as tokio for mainstream server applications and embassy for embedded async use cases. This separation lets the core logic run identically regardless of runtime, covering roughly 99% of use cases without duplicating implementation. Anyone choosing an async runtime strategy for cross-platform Rust libraries can follow this space on daily.dev."}}]}
```

