mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 10:15:31 +00:00
refactor aquatic_udp_protocol, notably make converters trait fns
This commit is contained in:
parent
2cf161469f
commit
ea6a4c2635
19 changed files with 774 additions and 809 deletions
|
|
@ -5,7 +5,7 @@ use hashbrown::HashMap;
|
|||
use parking_lot::Mutex;
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use aquatic_udp_protocol::types::*;
|
||||
use aquatic_udp_protocol::*;
|
||||
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use rand::distributions::WeightedIndex;
|
|||
use rand::prelude::*;
|
||||
use rand_distr::Pareto;
|
||||
|
||||
use aquatic_udp_protocol::types::*;
|
||||
use aquatic_udp_protocol::*;
|
||||
|
||||
use crate::common::*;
|
||||
use crate::utils::*;
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ use crossbeam_channel::{Receiver, Sender};
|
|||
use mio::{net::UdpSocket, Events, Poll, Interest, Token};
|
||||
use socket2::{Socket, Domain, Type, Protocol};
|
||||
|
||||
use aquatic_udp_protocol::converters::*;
|
||||
use aquatic_udp_protocol::types::*;
|
||||
use aquatic_udp_protocol::*;
|
||||
|
||||
use crate::common::*;
|
||||
|
||||
|
|
@ -131,7 +130,7 @@ fn read_responses(
|
|||
responses: &mut Vec<(ThreadId, Response)>,
|
||||
){
|
||||
while let Ok(amt) = socket.recv(buffer) {
|
||||
match response_from_bytes(&buffer[0..amt]){
|
||||
match Response::from_bytes(&buffer[0..amt]){
|
||||
Ok(response) => {
|
||||
match response {
|
||||
Response::Announce(ref r) => {
|
||||
|
|
@ -171,7 +170,7 @@ fn send_requests(
|
|||
while let Ok(request) = receiver.try_recv() {
|
||||
cursor.set_position(0);
|
||||
|
||||
if let Err(err) = request_to_bytes(&mut cursor, request){
|
||||
if let Err(err) = request.write(&mut cursor){
|
||||
eprintln!("request_to_bytes err: {}", err);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
|||
use rand_distr::{Standard, Pareto};
|
||||
use rand::prelude::*;
|
||||
|
||||
use aquatic_udp_protocol::types::*;
|
||||
use aquatic_udp_protocol::*;
|
||||
|
||||
use crate::common::*;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue