pub fn from_str(r#type: Type, s: &str) -> Result<Self, FromStrError> {
        Ok(match r#type {
            // IP Addresses
            Type::A => Resource::A(s.parse()?),
            Type::AAAA => Resource::AAAA(s.parse()?),

            // Simple strings (domains)
            Type::NS => Resource::NS(s.to_string()),
            Type::CNAME => Resource::CNAME(s.to_string()),
            Type::PTR => Resource::PTR(s.to_string()),

            // Complex types
            Type::MX => Resource::MX(s.parse()?),
            Type::SRV => Resource::SRV(s.parse()?),
            Type::SOA => Resource::SOA(s.parse()?),
            Type::SPF => Resource::SPF(s.parse()?),
            Type::TXT => Resource::TXT(s.parse()?),

            // This should never appear in a answer record unless we have invalid data.
            Type::Reserved | Type::OPT | Type::ANY => return Err(FromStrError::UnsupportedType),
        })
    }
// Similar to the FromStr but needs the record Type since they are ambiguous.
Similar to the FromStr but needs the record Type since they are ambiguous.
Similar to the FromStr but needs the record Type since they are ambiguous .
pub fn from_str(r#type: Type, s: &str) -> Result<Self, FromStrError> {
        Ok(match r#type {
            // IP Addresses
            Type::A => Resource::A(s.parse()?),
            Type::AAAA => Resource::AAAA(s.parse()?),
            // Simple strings (domains)
            Type::NS => Resource::NS(s.to_string()),
            Type::CNAME => Resource::CNAME(s.to_string()),
            Type::PTR => Resource::PTR(s.to_string()),
            // Complex types
            Type::MX => Resource::MX(s.parse()?),
            Type::SRV => Resource::SRV(s.parse()?),
            Type::SOA => Resource::SOA(s.parse()?),
            Type::SPF => Resource::SPF(s.parse()?),
            Type::TXT => Resource::TXT(s.parse()?),
            // This should never appear in a answer record unless we have invalid data.
            Type::Reserved | Type::OPT | Type::ANY => return Err(FromStrError::UnsupportedType),
        })
    }
pub fn from_str ( r#type : Type , s : & str ) -> Result < Self , FromStrError > { Ok ( match r#type { // IP Addresses Type :: A => Resource :: A ( s . parse ( ) ? ) , Type :: AAAA => Resource :: AAAA ( s . parse ( ) ? ) , // Simple strings (domains) Type :: NS => Resource :: NS ( s . to_string ( ) ) , Type :: CNAME => Resource :: CNAME ( s . to_string ( ) ) , Type :: PTR => Resource :: PTR ( s . to_string ( ) ) , // Complex types Type :: MX => Resource :: MX ( s . parse ( ) ? ) , Type :: SRV => Resource :: SRV ( s . parse ( ) ? ) , Type :: SOA => Resource :: SOA ( s . parse ( ) ? ) , Type :: SPF => Resource :: SPF ( s . parse ( ) ? ) , Type :: TXT => Resource :: TXT ( s . parse ( ) ? ) , // This should never appear in a answer record unless we have invalid data. Type :: Reserved | Type :: OPT | Type :: ANY => return Err ( FromStrError :: UnsupportedType ) , } ) }
Similar to the FromStr but needs the record Type since they are ambiguous.
Similar to the FromStr but needs the record Type since they are ambiguous .
r#type
Type
s
&str