upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/git/protocol.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-12-01 14:31:32 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-12-01 15:22:38 +0000
commitd2ac69816567f092fe0d4661723bc43778cb481b (patch)
treee8b51b61a6a7b0ab1a214adebe4e237143b01f0b /src/git/protocol.rs
parent7a78815e29b01c83f3d0ec195ba717a2eba8cd37 (diff)
fix cargo clippy and fmt warnings
Diffstat (limited to 'src/git/protocol.rs')
-rw-r--r--src/git/protocol.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/git/protocol.rs b/src/git/protocol.rs
index 93177de..8592c27 100644
--- a/src/git/protocol.rs
+++ b/src/git/protocol.rs
@@ -55,11 +55,11 @@ impl PktLine {
55 return Err(ProtocolError::InsufficientData); 55 return Err(ProtocolError::InsufficientData);
56 } 56 }
57 57
58 let len_str = std::str::from_utf8(&input[0..4]) 58 let len_str =
59 .map_err(|_| ProtocolError::InvalidLength)?; 59 std::str::from_utf8(&input[0..4]).map_err(|_| ProtocolError::InvalidLength)?;
60 60
61 let len = u16::from_str_radix(len_str, 16) 61 let len =
62 .map_err(|_| ProtocolError::InvalidLength)? as usize; 62 u16::from_str_radix(len_str, 16).map_err(|_| ProtocolError::InvalidLength)? as usize;
63 63
64 if len == 0 { 64 if len == 0 {
65 // Flush packet 65 // Flush packet
@@ -81,19 +81,19 @@ impl PktLine {
81 /// Parse all pkt-lines from bytes 81 /// Parse all pkt-lines from bytes
82 pub fn parse_all(mut input: &[u8]) -> Result<Vec<Self>, ProtocolError> { 82 pub fn parse_all(mut input: &[u8]) -> Result<Vec<Self>, ProtocolError> {
83 let mut packets = Vec::new(); 83 let mut packets = Vec::new();
84 84
85 while !input.is_empty() { 85 while !input.is_empty() {
86 let (packet, remaining) = Self::parse(input)?; 86 let (packet, remaining) = Self::parse(input)?;
87 let is_flush = matches!(packet, PktLine::Flush); 87 let is_flush = matches!(packet, PktLine::Flush);
88 packets.push(packet); 88 packets.push(packet);
89 input = remaining; 89 input = remaining;
90 90
91 // Stop at flush packet 91 // Stop at flush packet
92 if is_flush { 92 if is_flush {
93 break; 93 break;
94 } 94 }
95 } 95 }
96 96
97 Ok(packets) 97 Ok(packets)
98 } 98 }
99} 99}
@@ -259,4 +259,4 @@ mod tests {
259 "application/x-git-upload-pack-result" 259 "application/x-git-upload-pack-result"
260 ); 260 );
261 } 261 }
262} \ No newline at end of file 262}