Api to consume Extensions and import/export all items
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- rust
调研方向
先阅读 Extensions 和 AnyClone 类型,然后查看相关 issue #299 以及提议的 IntoIterator 示例。比较用于导出所有扩展项并将其导入新的或现有 Extensions 对象的各种 API。完成的标准是:项目拥有一个已达成共识且可用的互操作 API,而不是依赖嵌套 typemap 变通方案。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Rust
- 星标
- 1.4k
- 派生
- 378
- 平均合并
- 1 天 21 小时
- 30 天内合并 PR
- 5
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
hyperium/http 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 4/5 3-5 天 新手友好度 45/100
-
难度 3/5 1-2 天 新手友好度 62/100
-
难度 3/5 1-2 天 新手友好度 58/100
-
难度 3/5 1-2 天 新手友好度 62/100
相似的 Issue
-
bug
难度 1/5 1 小时以内 新手友好度 85/100
-
难度 2/5 1-3 小时 新手友好度 75/100
yantrikos/yantrik-os#255 ·
-
bug CLI custom-model
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 70/100
raphamorim/rio#1956 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
rust-bitcoin/rust-bitcoin#6930 · 1 条评论 ·