Add Copy trait to Valve Request Kind enum

This commit is contained in:
CosminPerRam 2022-12-31 14:52:17 +02:00
parent ef8ac92506
commit 7d164d40a1
2 changed files with 6 additions and 6 deletions

View file

@ -29,8 +29,8 @@ impl Packet {
Self {
header: initial.header,
kind: initial.kind,
payload: match initial.kind {
0x54 => {
payload: match kind {
Request::INFO => {
initial.payload.extend(challenge);
initial.payload
},
@ -42,7 +42,7 @@ impl Packet {
fn initial(kind: Request) -> Self {
Self {
header: 4294967295, //FF FF FF FF
kind: kind.clone() as u8,
kind: kind as u8,
payload: match kind {
Request::INFO => String::from("Source Engine Query\0").into_bytes(),
_ => vec![0xFF, 0xFF, 0xFF, 0xFF]
@ -179,7 +179,7 @@ impl ValveProtocol {
/// Ask for a specific request only.
fn get_request_data(&mut self, app: &App, protocol: u8, kind: Request) -> GDResult<Bufferer> {
let request_initial_packet = Packet::initial(kind.clone()).to_bytes();
let request_initial_packet = Packet::initial(kind).to_bytes();
self.socket.send(&request_initial_packet)?;
let packet = self.receive(app, protocol, PACKET_SIZE)?;
@ -190,7 +190,7 @@ impl ValveProtocol {
}
let challenge = packet.payload;
let challenge_packet = Packet::challenge(kind.clone(), challenge).to_bytes();
let challenge_packet = Packet::challenge(kind, challenge).to_bytes();
self.socket.send(&challenge_packet)?;

View file

@ -130,7 +130,7 @@ pub(crate) fn get_optional_extracted_data(data: Option<ExtraData>) -> (Option<u1
}
/// The type of the request, see the [protocol](https://developer.valvesoftware.com/wiki/Server_queries).
#[derive(PartialEq, Clone)]
#[derive(PartialEq, Copy, Clone)]
#[repr(u8)]
pub(crate) enum Request {
/// Known as `A2S_INFO`