fn new_null_terminated_from_buffer<BV: packet::BufferView<B>>(
        buffer: &mut BV,
    ) -> Result<Self, ValidStrError> {
        let v = buffer.as_ref();
        let eos = find_null_termination(&v).ok_or(ValidStrError::NoNullTermination)?;
        // Unwrap is safe, we just found null termination above.
        let bytes = buffer.take_front(eos + 1).unwrap();
        let (bytes, null_char) = bytes.split_at(eos);
        // TODO(https://github.com/rust-lang/rust/issues/82775): Use
        // debug_assert_matches from std when available.
        debug_assert!(
            matches!(null_char.as_ref(), [0]),
            "bad null character value: {:?}",
            null_char.as_ref()
        );
        let _ = null_char;
        Self::new(bytes).map_err(ValidStrError::Encoding)
    }
/// Attempts to create a new `ValidStr` from the provided `BufferView`,
/// consuming the buffer until the first null termination character.
///
/// The returned `ValidStr` will not contain the null character, but the
/// null character will be consumed from `buffer`.
///
/// Note that the bytes might be consumed from the buffer view even in case
/// of errors.
Attempts to create a new `ValidStr` from the provided `BufferView`,
consuming the buffer until the first null termination character.

The returned `ValidStr` will not contain the null character, but the
null character will be consumed from `buffer`.

Note that the bytes might be consumed from the buffer view even in case
of errors.
Attempts to create a new ` ValidStr ` from the provided ` BufferView ` consuming the buffer until the first null termination character . The returned ` ValidStr ` will not contain the null character but the null character will be consumed from ` buffer ` . Note that the bytes might be consumed from the buffer view even in case of errors .
fn new_null_terminated_from_buffer<BV: packet::BufferView<B>>(
        buffer: &mut BV,
    ) -> Result<Self, ValidStrError> {
        let v = buffer.as_ref();
        let eos = find_null_termination(&v).ok_or(ValidStrError::NoNullTermination)?;
        // Unwrap is safe, we just found null termination above.
        let bytes = buffer.take_front(eos + 1).unwrap();
        let (bytes, null_char) = bytes.split_at(eos);
        // TODO(https://github.com/rust-lang/rust/issues/82775): Use
        // debug_assert_matches from std when available.
        debug_assert!(
            matches!(null_char.as_ref(), [0]),
            "bad null character value: {:?}",
            null_char.as_ref()
        );
        let _ = null_char;
        Self::new(bytes).map_err(ValidStrError::Encoding)
    }
fn new_null_terminated_from_buffer < BV : packet :: BufferView < B > > ( buffer : & mut BV , ) -> Result < Self , ValidStrError > { let v = buffer . as_ref ( ) ; let eos = find_null_termination ( & v ) . ok_or ( ValidStrError :: NoNullTermination ) ? ; // Unwrap is safe, we just found null termination above. let bytes = buffer . take_front ( eos + 1 ) . unwrap ( ) ; let ( bytes , null_char ) = bytes . split_at ( eos ) ; // TODO(https://github.com/rust-lang/rust/issues/82775): Use // debug_assert_matches from std when available. debug_assert ! ( matches ( null_char as_ref ( ) [ 0 ] ) " " null_char as_ref ( ) ) ; let _ = null_char ; Self :: new ( bytes ) . map_err ( ValidStrError :: Encoding ) }
Attempts to create a new `ValidStr` from the provided `BufferView`,
consuming the buffer until the first null termination character.
Attempts to create a new ` ValidStr ` from the provided ` BufferView ` consuming the buffer until the first null termination character .
buffer
&mut BV
buffer
&mut BV