Skip to content

Commit

Permalink
Fix clippy::needless_as_bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
xnorpx authored and algesten committed Jan 10, 2025
1 parent 052e74f commit 5b20343
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/io/stun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ impl<'a> Attributes<'a> {
let username = self
.username
.map(|v| {
let pad = 4 - (v.as_bytes().len() % 4) % 4;
let pad = 4 - (v.len() % 4) % 4;
ATTR_TLV_LENGTH + v.len() + pad
})
.unwrap_or_default();
Expand Down Expand Up @@ -557,9 +557,9 @@ impl<'a> Attributes<'a> {
fn to_bytes(self, vec: &mut dyn Write, trans_id: &[u8]) -> io::Result<()> {
if let Some(v) = self.username {
vec.write_all(&Self::USERNAME.to_be_bytes())?;
vec.write_all(&(v.as_bytes().len() as u16).to_be_bytes())?;
vec.write_all(&(v.len() as u16).to_be_bytes())?;
vec.write_all(v.as_bytes())?;
let pad = 4 - (v.as_bytes().len() % 4) % 4;
let pad = 4 - (v.len() % 4) % 4;
for _ in 0..pad {
vec.write_all(&[0])?;
}
Expand Down
6 changes: 3 additions & 3 deletions src/rtp/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,19 +683,19 @@ impl Extension {
}
RtpStreamId => {
let v = ev.rid?;
let l = v.as_bytes().len();
let l = v.len();
buf[..l].copy_from_slice(v.as_bytes());
Some(l)
}
RepairedRtpStreamId => {
let v = ev.rid_repair?;
let l = v.as_bytes().len();
let l = v.len();
buf[..l].copy_from_slice(v.as_bytes());
Some(l)
}
RtpMid => {
let v = ev.mid?;
let l = v.as_bytes().len();
let l = v.len();
buf[..l].copy_from_slice(v.as_bytes());
Some(l)
}
Expand Down
2 changes: 1 addition & 1 deletion src/rtp/rtcp/sdes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl WordSized for Sdes {
.values
.iter()
// 2 here for 2 byte encoding of type + length
.map(|(_, s)| 2 + s.as_bytes().len())
.map(|(_, s)| 2 + s.len())
.sum::<usize>();

let padded = pad_bytes_to_word(byte_size);
Expand Down

0 comments on commit 5b20343

Please sign in to comment.