Mercurial > crates > nonstick
comparison libpam-sys/libpam-sys-helpers/src/lib.rs @ 149:14708d9061dc
Add safety section to BinaryPayload::total_bytes.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Mon, 07 Jul 2025 12:30:25 -0400 |
parents | 4b3a5095f68c |
children |
comparison
equal
deleted
inserted
replaced
148:4b3a5095f68c | 149:14708d9061dc |
---|---|
338 me.data_type = data_type; | 338 me.data_type = data_type; |
339 buf[5..].copy_from_slice(data) | 339 buf[5..].copy_from_slice(data) |
340 } | 340 } |
341 | 341 |
342 /// The total storage needed for the message, including header. | 342 /// The total storage needed for the message, including header. |
343 /// | |
344 /// # Safety | |
345 /// | |
346 /// The pointer must point to a valid `BinaryPayload`. | |
343 pub unsafe fn total_bytes(this: *const Self) -> usize { | 347 pub unsafe fn total_bytes(this: *const Self) -> usize { |
344 let header = this.as_ref().unwrap_unchecked(); | 348 let header = this.as_ref().unwrap_unchecked(); |
345 u32::from_be_bytes(header.total_bytes_u32be) as usize | 349 u32::from_be_bytes(header.total_bytes_u32be) as usize |
346 } | 350 } |
347 | 351 |