Improving `Interface` data structure by using generic data type
Maintainer thường phản hồi trong vòng 4 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 30/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- rust
- Lĩnh vực
- networking
Hướng nghiên cứu
The issue provides a Rust demo of a generic Interface<T> with BaseInterface and interface-specific data, but names no repository files or tests. First inspect the existing interface data structures and their callers to understand the scope and compatibility requirements. Done means the project’s interface representation uses the generic structure consistently and relevant tests pass; the issue has had no comment for 245 days, so check whether the direction is still wanted.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Demo code:
// SPDX-License-Identifier: Apache-2.0
#[derive(Debug, Default)]
enum InterfaceType {
#[default]
Unknown,
Bond,
LinuxBridge,
}
#[derive(Debug, Default)]
struct BaseInterface {
name: String,
iface_type: InterfaceType,
}
#[derive(Debug)]
struct BondInterface {
mode: u8,
}
#[derive(Debug)]
struct LinuxBridgeInterface {
stp: bool,
}
#[derive(Debug)]
struct Interface<T> {
base: BaseInterface,
specific: T,
}
impl<T> Interface<T> {
fn new_without_type(base: BaseInterface, specific: T) -> Self {
Self { base, specific }
}
fn name(&self) -> &str {
self.base.name.as_str()
}
}
impl Interface<LinuxBridgeInterface> {
fn new(base: BaseInterface, bridge: LinuxBridgeInterface) -> Self {
let mut rt = Self::new_without_type(base, bridge);
rt.base.iface_type = InterfaceType::LinuxBridge;
rt
}
fn stp(&self) -> bool {
self.specific.stp
}
}
impl Interface<BondInterface> {
fn new(base: BaseInterface, bond: BondInterface) -> Self {
let mut rt = Self::new_without_type(base, bond);
rt.base.iface_type = InterfaceType::Bond;
rt
}
fn mode(&self) -> u8 {
self.specific.mode
}
}
fn main() {
let mut bond = Interface::<BondInterface>::new(
BaseInterface {
name: "bond0".into(),
..Default::default()
},
BondInterface { mode: 0 },
);
bond.specific.mode = 1;
println!("Bond {} mode {}", bond.name(), bond.mode());
let mut bridge = Interface::<LinuxBridgeInterface>::new(
BaseInterface {
name: "bond0".into(),
..Default::default()
},
LinuxBridgeInterface { stp: false },
);
bridge.specific.stp = true;
println!("Bridge {} stp {}", bridge.name(), bridge.stp());
}
- Ngôn ngữ chính
- Rust
- Star
- 396
- Fork
- 121
- Merge trung bình
- 3 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 11
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của nmstate/nmstate
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 4 ngày
-
apply fails with ipv6.dns: this property is not allowed for 'method=disabled' when the active profile stores an IPv6 DNS serverCó thể đã có người làm @NopeCharon đã nhận 4 ngày trước. Đang mở
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 55/100
nmstate/nmstate#3251 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
nmstate/nmstate#3242 · 1 reaction ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Possible allocator mismatch: Go binding frees its own C.CString buffers with nmstate_cstring_free (CString::from_raw)Có thể đã có người làm @cvas22 đã nhận 6 ngày trước. Đang mở
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 62/100
nmstate/nmstate#3241 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
Tất cả issue của nmstate/nmstate
Issue tương tự
-
needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
mozilla-services/syncstorage-rs#2715 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
-
documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
physicsdolphin/nv-uefi-unlocker#53 · 4 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày