Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Rust work - #186

Draft
bootjp wants to merge 13 commits into
rustfrom
rust-work
Draft

Rust work#186
bootjp wants to merge 13 commits into
rustfrom
rust-work

Conversation

@bootjp

@bootjp bootjp commented Mar 26, 2023

Copy link
Copy Markdown
Member

No description provided.

@bootjp
bootjp changed the base branch from master to quic March 26, 2023 11:23
@bootjp
bootjp changed the base branch from quic to rust March 26, 2023 11:23
Comment thread src/client.rs Outdated
}

impl Client {
pub fn new(id: u16, addr: String) -> Result<Self, anyhow::Error> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここの addr の型 String じゃなくて UdpSocket::bind() の型に合わせたほうが良いかも

Suggested change
pub fn new(id: u16, addr: String) -> Result<Self, anyhow::Error> {
pub fn new(id: u16, addr: impl ToSocketAddrs) -> Result<Self, anyhow::Error> {

Comment thread src/client.rs Outdated

pub trait ClientTrait {
fn get_id(&self) -> u16;
fn get_id_byte(&self) -> &[u8];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u16 から [u8; 2] への変換コストそんなに重くない気がするので、フィールドで保持せずメソッドで都度変換でも良いような

Comment thread src/client.rs Outdated
self.id
}

fn get_id_byte(&self) -> &[u8] {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idu16 なのは公開情報だから、ここは要素数を抽象化せず &[u8; 2] の方が良いかも

Comment thread src/client.rs Outdated
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants