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

Rust work #186

Draft
wants to merge 13 commits into
base: rust
Choose a base branch
from
Draft

Rust work #186

wants to merge 13 commits into from

Conversation

bootjp
Copy link
Member

@bootjp bootjp commented Mar 26, 2023

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
src/client.rs Outdated
}

impl Client {
pub fn new(id: u16, addr: String) -> Result<Self, anyhow::Error> {
Copy link
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> {

src/client.rs Outdated

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

Choose a reason for hiding this comment

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

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

src/client.rs Outdated
self.id
}

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

Choose a reason for hiding this comment

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

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

src/client.rs Outdated Show resolved Hide resolved
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