Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`InvalidUri` errors could probably include the invalid bytes

Aperta
#571 8 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
42/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
rust
Ambito
networking

Direzione di ricerca

Individua il tipo InvalidUri e il percorso di parsing Uri::from_shared, quindi esamina le relative implementazioni di fmt::Display e fmt::Debug. Traccia gli altri metodi di parsing che convertono l’input in Bytes. Il lavoro è completato quando l’input non valido viene mantenuto nell’errore e incluso nel relativo output formattato, con test che coprono il valore dell’errore risultante e i messaggi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

The InvalidUri error type is returned when trying to parse an input as a URI, if the bytes are not a valid URI. This error type does not contain the value that we were trying to parse, but does indicate how the input was invalid.

Since all methods of parsing a value as a Uri either take a Bytes or convert the input (string or byte slice) into a Bytes, the error type probably could include the input, and format it as part of their fmt::Display/fmt::Debug implementations. Uri::from_shared takes a Bytes by value, so returning it in the error value shouldn't have a significant performance cost --- if we're trying to parse a URI from an &str or &[u8], we will have already copied it in order to convert it into a Bytes, and if the input was itself a Bytes, the reference count has already been incremented in order to call Uri::from_shared.

This would make it much easier for an application to display the invalid input to the user, which is desirable, especially in cases where the invalid URI came from user input.

Lingua principale
Rust
Stelle
1.4k
Fork
378
Merge medio
1g 21h
PR unite (30g)
5

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di hyperium/http

Tutte le issue di hyperium/http

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.