pub struct FileChunk {
pub file_id: String,
pub file_name: String,
pub file_size: u64,
pub total_chunks: u32,
pub chunk_index: u32,
pub chunk_data: Vec<u8>,
pub file_checksum: String,
}Expand description
A file chunk message.
Fields§
§file_id: StringUnique file identifier.
file_name: StringOriginal file name.
file_size: u64Total file size in bytes.
total_chunks: u32Total number of chunks.
chunk_index: u32Index of this chunk (0-based).
chunk_data: Vec<u8>Chunk data (base64-encoded in JSON).
file_checksum: StringChecksum of the complete file (SHA256 hex string).
Implementations§
Source§impl FileChunk
impl FileChunk
Sourcepub fn to_json(&self) -> Result<String, Error>
pub fn to_json(&self) -> Result<String, Error>
Serializes to JSON (kept for backward compatibility).
Sourcepub fn from_json(json: &str) -> Result<Self, Error>
pub fn from_json(json: &str) -> Result<Self, Error>
Deserializes from JSON (kept for backward compatibility).
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serializes to a compact binary format, avoiding base64/JSON overhead.
Wire format (all multi-byte integers are little-endian):
[file_id_len:4][file_id][file_name_len:4][file_name]
[file_size:8][total_chunks:4][chunk_index:4]
[chunk_data_len:4][chunk_data]
[checksum_len:4][checksum]Sourcepub fn from_bytes(data: &[u8]) -> Result<Self, ChunkDecodeError>
pub fn from_bytes(data: &[u8]) -> Result<Self, ChunkDecodeError>
Deserializes from the compact binary format produced by to_bytes.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for FileChunk
impl<'de> Deserialize<'de> for FileChunk
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for FileChunk
impl RefUnwindSafe for FileChunk
impl Send for FileChunk
impl Sync for FileChunk
impl Unpin for FileChunk
impl UnsafeUnpin for FileChunk
impl UnwindSafe for FileChunk
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more