comparison libpam-sys/src/helpers.rs @ 117:20f7712a6857

Neaten up libpam-sys BinaryPayload buffer management.
author Paul Fisher <paul@pfish.zone>
date Sun, 29 Jun 2025 18:48:14 -0400
parents 2346fd501b7a
children 39760dfc9b3b
comparison
equal deleted inserted replaced
116:a12706e42c9d 117:20f7712a6857
131 } 131 }
132 132
133 /// The total bytes needed to store this, including the header. 133 /// The total bytes needed to store this, including the header.
134 pub fn total_bytes(&self) -> usize { 134 pub fn total_bytes(&self) -> usize {
135 unsafe { 135 unsafe {
136 self.0 136 BinaryPayload::buffer_of(self.0.as_ptr().cast()).len()
137 .as_ptr()
138 .cast::<BinaryPayload>()
139 .as_ref()
140 .unwrap_unchecked()
141 .total_bytes()
142 } 137 }
143 } 138 }
144 139
145 /// Unwraps this into the raw storage backing it. 140 /// Unwraps this into the raw storage backing it.
146 pub fn into_inner(self) -> O { 141 pub fn into_inner(self) -> O {