pub fn validate(&self) -> Result<(), Error> {
        lazy_static! {
            static ref UA_VERSION: Regex = Regex::new(r"^[\d\.]+$").unwrap();
        }
        if self.max_wait_time < 1 || self.max_wait_time > 120 {
            error!(
                "validate - max_wait_time must be between 1..120 ({})",
                self.max_wait_time
            );
            return Err(Error::MessageFormat(MessageErrorKind::InvalidFieldValue));
        }
        if self.spec_version >= SpecVersion::V11 {
            if let Some(user_agent) = &self.product_and_version {
                if user_agent.name.contains('/') || !UA_VERSION.is_match(&user_agent.version) {
                    error!(
                        "validate - user_agent needs to match 'ProductName/Version' ({:?})",
                        user_agent
                    );
                    return Err(Error::MessageFormat(MessageErrorKind::InvalidFieldValue));
                }
            }
        }
        if self.spec_version >= SpecVersion::V20 {
            if self.control_point.is_none() {
                error!("validate - control_point required");
                return Err(Error::MessageFormat(MessageErrorKind::InvalidFieldValue));
            } else if let Some(control_point) = &self.control_point {
                if control_point.friendly_name.is_empty() {
                    error!("validate - control_point.friendly_name required");
                    return Err(Error::MessageFormat(MessageErrorKind::InvalidFieldValue));
                }
            }
        }
        Ok(())
    }
///
/// Validate all options, ensuring values as well as version-specific rules.
///
Validate all options, ensuring values as well as version-specific rules.
Validate all options ensuring values as well as version - specific rules .
pub fn validate(&self) -> Result<(), Error> {
        lazy_static! {
            static ref UA_VERSION: Regex = Regex::new(r"^[\d\.]+$").unwrap();
        }
        if self.max_wait_time < 1 || self.max_wait_time > 120 {
            error!(
                "validate - max_wait_time must be between 1..120 ({})",
                self.max_wait_time
            );
            return Err(Error::MessageFormat(MessageErrorKind::InvalidFieldValue));
        }
        if self.spec_version >= SpecVersion::V11 {
            if let Some(user_agent) = &self.product_and_version {
                if user_agent.name.contains('/') || !UA_VERSION.is_match(&user_agent.version) {
                    error!(
                        "validate - user_agent needs to match 'ProductName/Version' ({:?})",
                        user_agent
                    );
                    return Err(Error::MessageFormat(MessageErrorKind::InvalidFieldValue));
                }
            }
        }
        if self.spec_version >= SpecVersion::V20 {
            if self.control_point.is_none() {
                error!("validate - control_point required");
                return Err(Error::MessageFormat(MessageErrorKind::InvalidFieldValue));
            } else if let Some(control_point) = &self.control_point {
                if control_point.friendly_name.is_empty() {
                    error!("validate - control_point.friendly_name required");
                    return Err(Error::MessageFormat(MessageErrorKind::InvalidFieldValue));
                }
            }
        }
        Ok(())
    }
pub fn validate ( & self ) -> Result < ( ) , Error > { lazy_static ! { static ref UA_VERSION Regex Regex new ( r"^[\d\.]+$" ) unwrap ( ) } if self . max_wait_time < 1 || self . max_wait_time > 120 { error ! ( " " self max_wait_time ) ; return Err ( Error :: MessageFormat ( MessageErrorKind :: InvalidFieldValue ) ) ; } if self . spec_version >= SpecVersion :: V11 { if let Some ( user_agent ) = & self . product_and_version { if user_agent . name . contains ( '/' ) || ! UA_VERSION . is_match ( & user_agent . version ) { error ! ( " " user_agent ) ; return Err ( Error :: MessageFormat ( MessageErrorKind :: InvalidFieldValue ) ) ; } } } if self . spec_version >= SpecVersion :: V20 { if self . control_point . is_none ( ) { error ! ( " " ) ; return Err ( Error :: MessageFormat ( MessageErrorKind :: InvalidFieldValue ) ) ; } else if let Some ( control_point ) = & self . control_point { if control_point . friendly_name . is_empty ( ) { error ! ( " " ) ; return Err ( Error :: MessageFormat ( MessageErrorKind :: InvalidFieldValue ) ) ; } } } Ok ( ( ) ) }
Validate all options, ensuring values as well as version-specific rules.
Validate all options ensuring values as well as version - specific rules .
&self
&self