Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1bebf10db2 | ||
|
|
21e0e7a113 | ||
|
|
c8213ce5a2 |
No files matched your search
+15
-7
@@ -9,24 +9,32 @@ pub struct BaseHeader {
|
||||
os: Os,
|
||||
}
|
||||
|
||||
impl From<BaseHeader> for [u8; 10] {
|
||||
fn from(header: BaseHeader) -> Self {
|
||||
let mtime: [u8; 4] = header.last_modified.into();
|
||||
impl BaseHeader {
|
||||
const SIZE: usize = 10;
|
||||
|
||||
fn to_bytes(self) -> [u8; Self::SIZE] {
|
||||
let mtime: [u8; 4] = self.last_modified.into();
|
||||
[
|
||||
ID1,
|
||||
ID2,
|
||||
header.compression_method.into(),
|
||||
header.flags.0,
|
||||
self.compression_method.into(),
|
||||
self.flags.0,
|
||||
mtime[0],
|
||||
mtime[1],
|
||||
mtime[2],
|
||||
mtime[3],
|
||||
header.extra_flags.0,
|
||||
header.os.into(),
|
||||
self.extra_flags.0,
|
||||
self.os.into(),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
impl From<BaseHeader> for [u8; 10] {
|
||||
fn from(header: BaseHeader) -> Self {
|
||||
header.to_bytes()
|
||||
}
|
||||
}
|
||||
|
||||
pub enum CompressionMethod {
|
||||
Deflate,
|
||||
}
|
||||
|
||||
+2
-2
@@ -25,14 +25,14 @@ impl From<ExtraFieldHeader> for Vec<u8> {
|
||||
}
|
||||
|
||||
impl From<ExtraSubField> for Vec<u8> {
|
||||
fn from(mut extra_sub_field: ExtraSubField) -> Self {
|
||||
fn from(extra_sub_field: ExtraSubField) -> Self {
|
||||
let mut result = Vec::new();
|
||||
let len = extra_sub_field.field.len().to_le_bytes();
|
||||
result.push(extra_sub_field.subfield_id1);
|
||||
result.push(extra_sub_field.subfield_id2);
|
||||
result.push(len[0]);
|
||||
result.push(len[1]);
|
||||
result.append(&mut extra_sub_field.field);
|
||||
result.append(&mut extra_sub_field.field.clone());
|
||||
result
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user