feat[rust]: compatible protocol

This commit is contained in:
godotg
2024-07-21 15:38:09 +08:00
parent f252aec9c1
commit 2a3ba9995b
3 changed files with 6 additions and 1 deletions
@@ -51,6 +51,10 @@ impl IByteBuffer for ByteBuffer {
}
}
fn compatibleRead(&mut self, beforeReadIndex: i32, length: i32) -> bool{
return length != -1 && self.getReadOffset() < length + beforeReadIndex;
}
fn getBuffer(&self) -> &Vec<i8> {
return &self.buffer;
}
@@ -13,6 +13,7 @@ pub trait IPacket {
#[allow(unused_parens)]
pub trait IByteBuffer {
fn adjustPadding(&mut self, predictionLength: i32, beforeWriteIndex: i32);
fn compatibleRead(&mut self, beforeReadIndex: i32, length: i32) -> bool;
fn getBuffer(&self) -> &Vec<i8>;
fn getWriteOffset(&self) -> i32;
fn setWriteOffset(&mut self, writeIndex: i32);