Skip to content

tls_codec: preliminary no_std support - #291

Merged
tarcieri merged 1 commit into
masterfrom
tls_codec/no_std
Dec 20, 2021
Merged

tarcieri merged 1 commit into
masterfrom
tls_codec/no_std

Conversation

@tarcieri

Copy link
Copy Markdown
Member

Adds initial support for no_std targets (currently with a hard alloc dependency) by gating all std-related functionality on a newly added eponymous crate feature.

Unfortunately all serialization/deserialization is currently performed in terms of the Read and Write traits from std::io, so this doesn't result in something immediately useful on no_std targets. However, it does provide the initial boilerplate and first steps towards making that possible.

Adds initial support for `no_std` targets (currently with a hard `alloc`
dependency) by gating all `std`-related functionality on a newly added
eponymous crate feature.

Unfortunately all serialization/deserialization is currently performed
in terms of the `Read` and `Write` traits from `std::io`, so this
doesn't result in something immediately useful on `no_std` targets.
However, it does provide the initial boilerplate and first steps towards
making that possible.
@tarcieri tarcieri changed the title tls_codec: preliminary no_std support tls_codec: preliminary no_std support Dec 19, 2021
@tarcieri

tarcieri commented Dec 19, 2021 •

Copy link
Copy Markdown
Member Author

The next steps I'd suggest after this would be defining replacement traits for std::io::{Read, Write} which provide the subset of functionality currently used by this crate, so that they can always be available regardless of whether or not the std feature is enabled.

When the std feature is enabled, blanket impls of these traits can be defined for the corresponding std::io traits, so everything continues to work with them.

@franziskuskiefer franziskuskiefer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Definitely a good start for tackling this.

Right now there's no good way to do this without Read and Write I'm afraid.
There's some discussion around this happening. It's all over the place but rust-lang/rfcs#2262 looks like a good issue to follow.

If we want to have something done before there's a solution that allows us using the traits, we could add a separate API that operates on byte slices/vectors.

@tarcieri

Copy link
Copy Markdown
Member Author

Cool. Will merge this and we can follow up on what to do about new no_std friendly APIs.

@tarcieri
tarcieri merged commit 25626b8 into master Dec 20, 2021
@tarcieri
tarcieri deleted the tls_codec/no_std branch December 20, 2021 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants