pub struct Message {
pub cards: Vec<Card>,
}Expand description
A sync protocol message (request or response).
Fields§
§cards: Vec<Card>Implementations§
Source§impl Message
impl Message
Sourcepub fn encode(&self) -> Result<Vec<u8>>
pub fn encode(&self) -> Result<Vec<u8>>
Encode the message to bytes (compressed with size prefix).
Heroforge’s HTTP sync protocol uses a 4-byte big-endian size prefix (uncompressed size) before the zlib-compressed data.
Sourcepub fn to_text(&self) -> Result<String>
pub fn to_text(&self) -> Result<String>
Encode the message to text (uncompressed, for debugging).
Sourcepub fn decode(data: &[u8]) -> Result<Self>
pub fn decode(data: &[u8]) -> Result<Self>
Decode a message from compressed bytes.
This properly handles binary file content within the message.
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self>
pub fn from_bytes(data: &[u8]) -> Result<Self>
Parse a message from uncompressed bytes.
This handles binary file/cfile content properly.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)