pub unsafe fn from_bytes_ascii(name: &[u8]) -> Result<Self, NameParseError> {

        if name.len() > 255 {
            return Err(NameParseError::NameTooLarge(
                String::from_utf8_unchecked(name.into())));
        }

        let mut splits
            = name.split(|v| b'.' == *v).enumerate().peekable();

        while let Some((position, split)) = splits.next() {
            if split.len() > 63 {
                return Err(NameParseError::LabelTooLong(
                    String::from_utf8_unchecked(split.into())));
            }

            if split.is_empty() && splits.peek().is_some() {
                return Err(NameParseError::EmptyLabel(position));
            }
        };

        Self::from_bytes_raw(name)
    }
/// This function is unsafe because there is no checks made to ensure the given
/// &[u8] is ascii u8 slice
///
/// This the responsibility of the caller to ensure the &[u8] is a u8 slice of ascii
/// characters
This function is unsafe because there is no checks made to ensure the given
&[u8] is ascii u8 slice

This the responsibility of the caller to ensure the &[u8] is a u8 slice of ascii
characters
This function is unsafe because there is no checks made to ensure the given & [ u8 ] is ascii u8 slice This the responsibility of the caller to ensure the & [ u8 ] is a u8 slice of ascii characters
pub unsafe fn from_bytes_ascii(name: &[u8]) -> Result<Self, NameParseError> {
        if name.len() > 255 {
            return Err(NameParseError::NameTooLarge(
                String::from_utf8_unchecked(name.into())));
        }
        let mut splits
            = name.split(|v| b'.' == *v).enumerate().peekable();
        while let Some((position, split)) = splits.next() {
            if split.len() > 63 {
                return Err(NameParseError::LabelTooLong(
                    String::from_utf8_unchecked(split.into())));
            }
            if split.is_empty() && splits.peek().is_some() {
                return Err(NameParseError::EmptyLabel(position));
            }
        };
        Self::from_bytes_raw(name)
    }
pub unsafe fn from_bytes_ascii ( name : & [ u8 ] ) -> Result < Self , NameParseError > { if name . len ( ) > 255 { return Err ( NameParseError :: NameTooLarge ( String :: from_utf8_unchecked ( name . into ( ) ) ) ) ; } let mut splits = name . split ( | v | b'.' == * v ) . enumerate ( ) . peekable ( ) ; while let Some ( ( position , split ) ) = splits . next ( ) { if split . len ( ) > 63 { return Err ( NameParseError :: LabelTooLong ( String :: from_utf8_unchecked ( split . into ( ) ) ) ) ; } if split . is_empty ( ) && splits . peek ( ) . is_some ( ) { return Err ( NameParseError :: EmptyLabel ( position ) ) ; } } ; Self :: from_bytes_raw ( name ) }
This function is unsafe because there is no checks made to ensure the given
&[u8] is ascii u8 slice
This function is unsafe because there is no checks made to ensure the given & [ u8 ] is ascii u8 slice
name
&[u8]
name
&[u8]