add debug logging to ticket generation for debugging
This commit is contained in:
parent
b6b7d2559d
commit
4ad883a54d
10 changed files with 223 additions and 127 deletions
|
|
@ -1,12 +1,12 @@
|
|||
use std::{fmt, io};
|
||||
use crate::rmc::structures::helpers::DummyWriter;
|
||||
use std::io::{Read, Write};
|
||||
use std::string::FromUtf8Error;
|
||||
use std::{fmt, io};
|
||||
use thiserror::Error;
|
||||
use crate::rmc::structures::helpers::DummyWriter;
|
||||
//ideas for the future: make a proc macro library which allows generation of struct reads
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error{
|
||||
pub enum Error {
|
||||
#[error("Io Error: {0}")]
|
||||
Io(#[from] io::Error),
|
||||
#[error("UTF8 conversion Error: {0}")]
|
||||
|
|
@ -18,51 +18,52 @@ pub enum Error{
|
|||
#[error("an error occurred reading the station url")]
|
||||
StationUrlInvalid,
|
||||
#[error("error formatting text: {0}")]
|
||||
FormatError(#[from] fmt::Error)
|
||||
FormatError(#[from] fmt::Error),
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
pub mod string;
|
||||
pub mod any;
|
||||
pub mod qresult;
|
||||
pub mod buffer;
|
||||
pub mod connection_data;
|
||||
pub mod rmc_struct;
|
||||
pub mod list;
|
||||
pub mod qbuffer;
|
||||
pub mod primitives;
|
||||
pub mod matchmake;
|
||||
pub mod variant;
|
||||
pub mod ranking;
|
||||
pub mod networking;
|
||||
pub mod helpers;
|
||||
pub mod list;
|
||||
pub mod matchmake;
|
||||
pub mod networking;
|
||||
pub mod primitives;
|
||||
pub mod qbuffer;
|
||||
pub mod qresult;
|
||||
pub mod ranking;
|
||||
pub mod rmc_struct;
|
||||
pub mod string;
|
||||
pub mod variant;
|
||||
|
||||
pub trait RmcSerialize{
|
||||
pub trait RmcSerialize {
|
||||
fn serialize(&self, writer: &mut impl Write) -> Result<()>;
|
||||
fn serialize_write_size(&self) -> Result<u32>{
|
||||
fn serialize_write_size(&self) -> Result<u32> {
|
||||
let mut dummy = DummyWriter::new();
|
||||
|
||||
self.serialize(&mut dummy)?;
|
||||
|
||||
Ok(dummy.get_total_len())
|
||||
}
|
||||
fn deserialize(reader: &mut impl Read) -> Result<Self> where Self: Sized;
|
||||
fn deserialize(reader: &mut impl Read) -> Result<Self>
|
||||
where
|
||||
Self: Sized;
|
||||
|
||||
fn to_data(&self) -> Result<Vec<u8>>{
|
||||
let mut data = Vec::with_capacity(
|
||||
self.serialize_write_size()? as usize
|
||||
);
|
||||
fn to_data(&self) -> Result<Vec<u8>> {
|
||||
let expected_size = self.serialize_write_size()?;
|
||||
let mut data = Vec::with_capacity(expected_size as usize);
|
||||
|
||||
self.serialize(&mut data)?;
|
||||
|
||||
debug_assert_eq!(self.serialize_write_size().unwrap(), data.len() as u32);
|
||||
debug_assert_eq!(expected_size, data.len() as u32);
|
||||
|
||||
Ok(data)
|
||||
}
|
||||
}
|
||||
|
||||
impl RmcSerialize for (){
|
||||
impl RmcSerialize for () {
|
||||
fn serialize(&self, _writer: &mut impl Write) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -72,6 +73,4 @@ impl RmcSerialize for (){
|
|||
fn serialize_write_size(&self) -> Result<u32> {
|
||||
Ok(0)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue