Skip to content

Make tls_codec_derive compatible with #![no_std] #1106

@imor

Description

@imor

The tls_codec_derive crate currently unconditionally refers to items from stdlib. For example this line uses std::mem::size_of. Similarly this line refers to std::io::Write. These direct unconditional references makes it impossible to use tls_codec_derive from a #![no_std] crate. The code needs to be updated so that the crate can be used in a #![no_std] environment.

To attack this problem two broad techniques will be useful:

  1. Wherever possible replace a std reference with either a core reference or an alloc reference. For example, std::mem::size_of can be replaced with core::mem::size_of. Presence of liballoc can be assumed, see this comment.
  2. For the references which are not reexported from libcore or liballoc, feature gate them on a new std feature. For example std::io::Write is such a reference. This std feature should be enabled if the corresponding std feature in the tls_codec crate is enabled.

Ideally a failing test case should be written as well but I'm not sure if CI builds the crates in a #![no_std] environment or not. Maybe @tarcieri or @franziskuskiefer know about it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions