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

Api to consume Extensions and import/export all items

Aperta
#780 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
rust

Direzione di ricerca

Inizia leggendo i tipi Extensions e AnyClone, quindi esamina la issue correlata #299 e l’esempio IntoIterator proposto. Confronta le possibili API per esportare tutti gli elementi delle estensioni e importarli in un oggetto Extensions nuovo o esistente. Il lavoro sarà considerato completato quando il progetto disporrà di un’API di interoperabilità concordata e utilizzabile, invece di dipendere da workaround basati su typemap annidati.

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

Descrizione

When traversing boundaries it's currently quite hard (nearly impossible) to extract all extensions and transfer them to somewhere else. There are some creative ways to work around this, like inserting a nested typemap into extensions, but these are all quite hacky.

Would you be open into some sort of api that can consume extensions and return the individual items, and then later add these back to a new or existing Extension object?

A very quick solution could be something like

impl IntoIterator for Extensions {
    type Item = (TypeId, Box<dyn AnyClone + Send + Sync>);
    type IntoIter = std::vec::IntoIter<Self::Item>;

    fn into_iter(self) -> Self::IntoIter {
        match self.map {
            None => Default::default(),
            Some(map) => {
                map.into_iter().collect::<Vec<_>>().into_iter()
            }
        }
        
    }
}

But it could be anything else, only requirement would be the functionality to export all items from extensions and import them back again. The example implementation also hides away the usage of a hashmap so this detail could be changed in the future if needed. But it does require AnyClone to be public (can be sealed). Please don't focus on this solution too much as I haven't really given it much thought, it's just here as an example / starting point.

I'm really open to all suggestions here on how to support this or what other solutions there might be available. Having extensions be interoperable with other type maps would be really useful and would make extensions much more flexible.

This is slightly related to https://github.com/hyperium/http/issues/299

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.