Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

idna: Support no_alloc idna validator #1027

Open
al8n opened this issue Feb 8, 2025 · 3 comments
Open

idna: Support no_alloc idna validator #1027

al8n opened this issue Feb 8, 2025 · 3 comments

Comments

@al8n
Copy link

al8n commented Feb 8, 2025

Hi, the current idna crate supports no_std, but it cannot compile without alloc feature. Sometimes, users may only want to check if a &str is a valid international domain name and do not need to convert it to either unicode or ascii. For the validator, it should be possible to be implemented without alloc.

@hsivonen
Copy link
Collaborator

This would require the core of icu_normalizer to have a no-alloc mode. The issue is that the input may have an unbounded sequence of characters whose canonical combining class is non-zero, so there's no stack-allocated buffer size that would be long enough for arbitrary input.

Even if the stack-allocated buffer size was 32 Rust chars based on the "stream-safe" definition, there would need to be an answer for what happens when the input isn't "stream-safe". Making the current interface that transforms an iterator over char into another iterator over char produce an iterator over Result<char> instead and having possible return points all over the place would be disruptive for a relative specialized use case.

How common is it to have code that doesn't have alloc but that deals with domain names?

@nikki-aranya
Copy link

How common is it to have code that doesn't have alloc but that deals with domain names?

Extremely common. Embedded often uses the Embassy ecosystem, and includes embassy-net which is both no_std and no_alloc and would benefit greatly from being able to add urls to their custom IpAddress to use for e.g. TcpSocket, as well as something like embedded-nal. I was just looking into whether I could create a FixedUrl<const N: usize> using something like heapless and came across this issue.

@hsivonen
Copy link
Collaborator

includes embassy-net which is both no_std and no_alloc and would benefit greatly from being able to add urls to their custom IpAddress to use for e.g. TcpSocket, as well as something like embedded-nal.

The OP wanted just validation without an allocator (use case not explained), but this seems to imply running the "ToASCII" operation without an allocator, since that's needed when actually opening connections. Do I understand correctly?

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

No branches or pull requests

3 participants