pub fn new<T: Into<Cow<'a, str>>>(name: T) -> Result<Self, DatabaseNameError> {
        let name: Cow<'a, str> = name.into();

        if !LENGTH_CONSTRAINT.contains(&name.len()) {
            return Err(DatabaseNameError::LengthConstraint {
                name: name.to_string(),
            });
        }

        // Validate the name contains only valid characters.
        //
        // NOTE: If changing these characters, please update the error message
        // above.
        if let Some(bad_char_offset) = name.chars().position(|c| c.is_control()) {
            return BadCharsSnafu {
                bad_char_offset,
                name,
            }
            .fail();
        };

        Ok(Self(name))
    }
/// Create a new, valid DatabaseName.
Create a new, valid DatabaseName.
Create a new valid DatabaseName .
pub fn new<T: Into<Cow<'a, str>>>(name: T) -> Result<Self, DatabaseNameError> {
        let name: Cow<'a, str> = name.into();
        if !LENGTH_CONSTRAINT.contains(&name.len()) {
            return Err(DatabaseNameError::LengthConstraint {
                name: name.to_string(),
            });
        }
        // Validate the name contains only valid characters.
        //
        // NOTE: If changing these characters, please update the error message
        // above.
        if let Some(bad_char_offset) = name.chars().position(|c| c.is_control()) {
            return BadCharsSnafu {
                bad_char_offset,
                name,
            }
            .fail();
        };
        Ok(Self(name))
    }
pub fn new < T : Into < Cow < ' a , str > > > ( name : T ) -> Result < Self , DatabaseNameError > { let name : Cow < ' a , str > = name . into ( ) ; if ! LENGTH_CONSTRAINT . contains ( & name . len ( ) ) { return Err ( DatabaseNameError :: LengthConstraint { name : name . to_string ( ) , } ) ; } // Validate the name contains only valid characters. // // NOTE: If changing these characters, please update the error message // above. if let Some ( bad_char_offset ) = name . chars ( ) . position ( | c | c . is_control ( ) ) { return BadCharsSnafu { bad_char_offset , name , } . fail ( ) ; } ; Ok ( Self ( name ) ) }
Create a new, valid DatabaseName.
Create a new valid DatabaseName .
name
T
name
T