Enum msi::Category

source ·
pub enum Category {
Show 26 variants Text, UpperCase, LowerCase, Integer, DoubleInteger, TimeDate, Identifier, Property, Filename, WildCardFilename, Path, Paths, AnyPath, DefaultDir, RegPath, Formatted, FormattedSddlText, Template, Condition, Guid, Version, Language, Binary, CustomSource, Cabinet, Shortcut,
}
Expand description

Indicates the format of a string-typed database column.

This list of categories comes from the column data types listed in the MSI docs.

Variants§

§

Text

An unrestricted text string.

For more details, see the MSI docs for this data type.

Examples

assert!(msi::Category::Text.validate("Hello, World!"));
§

UpperCase

A text string containing no lowercase letters.

For more details, see the MSI docs for this data type.

Examples

// Valid:
assert!(msi::Category::UpperCase.validate("HELLO, WORLD!"));
// Invalid:
assert!(!msi::Category::UpperCase.validate("Hello, World!"));
§

LowerCase

A text string containing no uppercase letters.

For more details, see the MSI docs for this data type.

Examples

// Valid:
assert!(msi::Category::LowerCase.validate("hello, world!"));
// Invalid:
assert!(!msi::Category::LowerCase.validate("Hello, World!"));
§

Integer

A signed 16-bit integer.

For more details, see the MSI docs for this data type.

Examples

// Valid:
assert!(msi::Category::Integer.validate("32767"));
assert!(msi::Category::Integer.validate("-47"));
// Invalid:
assert!(!msi::Category::Integer.validate("40000"));
§

DoubleInteger

A signed 32-bit integer.

For more details, see the MSI docs for this data type.

Examples

// Valid:
assert!(msi::Category::DoubleInteger.validate("2147483647"));
assert!(msi::Category::DoubleInteger.validate("-99999"));
// Invalid:
assert!(!msi::Category::DoubleInteger.validate("3000000000"));
§

TimeDate

Stores a civil datetime, with a 2-second resolution.

For more details, see the MSI docs for this data type.

§

Identifier

A string identifier (such as a table or column name). May only contain alphanumerics, underscores, and periods, and must start with a letter or underscore.

For more details, see the MSI docs for this data type.

Examples

// Valid:
assert!(msi::Category::Identifier.validate("HelloWorld"));
assert!(msi::Category::Identifier.validate("_99.Bottles"));
// Invalid:
assert!(!msi::Category::Identifier.validate("$HELLO"));
assert!(!msi::Category::Identifier.validate("3.14159"));
§

Property

A string that is either an identifier (see above), or a reference to an environment variable (which consists of a % character followed by an identifier).

For more details, see the MSI docs for this data type.

Examples

// Valid:
assert!(msi::Category::Property.validate("HelloWorld"));
assert!(msi::Category::Property.validate("%HelloWorld"));
// Invalid:
assert!(!msi::Category::Property.validate("%"));
assert!(!msi::Category::Property.validate("Hello%World"));
§

Filename

The name of a file or directory.

For more details, see the MSI docs for this data type.

§

WildCardFilename

A filename that can contain shell glob wildcards.

For more details, see the MSI docs for this data type.

§

Path

A string containing an absolute filepath.

For more details, see the MSI docs for this data type.

§

Paths

A string containing a semicolon-separated list of absolute filepaths.

For more details, see the MSI docs for this data type.

§

AnyPath

A string containing an absolute or relative filepath.

For more details, see the MSI docs for this data type.

§

DefaultDir

A string containing either a filename or an identifier.

For more details, see the MSI docs for this data type.

§

RegPath

A string containing a registry path.

For more details, see the MSI docs for this data type.

§

Formatted

A string containing special formatting escapes, such as environment variables.

For more details, see the MSI docs for this data type.

§

FormattedSddlText

A security descriptor definition language (SDDL) text string written in valid Security Descriptor String Format.

For more details, see the MSI docs for this data type.

§

Template

Like Formatted, but allows additional escapes.

For more details, see the MSI docs for this data type.

§

Condition

A string represeting a boolean predicate.

For more details, see the MSI docs for this data type.

§

Guid

A hyphenated, uppercase GUID string, enclosed in curly braces.

For more details, see the MSI docs for this data type.

Examples

// Valid:
assert!(msi::Category::Guid.validate(
    "{34AB5C53-9B30-4E14-AEF0-2C1C7BA826C0}"));
// Invalid:
assert!(!msi::Category::Guid.validate(
    "{34AB5C539B304E14AEF02C1C7BA826C0}")); // Must be hyphenated
assert!(!msi::Category::Guid.validate(
    "{34ab5c53-9b30-4e14-aef0-2c1c7ba826c0}")); // Must be uppercase
assert!(!msi::Category::Guid.validate(
    "34AB5C53-9B30-4E14-AEF0-2C1C7BA826C0")); // Must have braces
assert!(!msi::Category::Guid.validate(
    "{HELLOWO-RLDH-ELLO-WORL-DHELLOWORLD0}"));
§

Version

A string containing a version number. The string must consist of at most four period-separated numbers, with the value of each number being at most 65535.

For more details, see the MSI docs for this data type.

Examples

// Valid:
assert!(msi::Category::Version.validate("1"));
assert!(msi::Category::Version.validate("1.22"));
assert!(msi::Category::Version.validate("1.22.3"));
assert!(msi::Category::Version.validate("1.22.3.444"));
// Invalid:
assert!(!msi::Category::Version.validate("1.99999"));
assert!(!msi::Category::Version.validate(".12"));
assert!(!msi::Category::Version.validate("1.2.3.4.5"));
§

Language

A string containing a comma-separated list of decimal language ID numbers.

For more details, see the MSI docs for this data type.

Examples

// Valid:
assert!(msi::Category::Language.validate("1033"));
assert!(msi::Category::Language.validate("1083,2107,3131"));
// Invalid:
assert!(!msi::Category::Language.validate(""));
assert!(!msi::Category::Language.validate("1083,2107,3131,"));
assert!(!msi::Category::Language.validate("1083,,3131"));
assert!(!msi::Category::Language.validate("en-US"));
§

Binary

A string that refers to a binary data stream.

For more details, see the MSI docs for this data type.

§

CustomSource

A string that refers to a custom source.

For more details, see the MSI docs for this data type.

§

Cabinet

A string that refers to a cabinet. If it starts with a # character, then the rest of the string is an identifier (see above) indicating a data stream in the package where the cabinet is stored. Otherwise, the string is a short filename (at most eight characters, a period, and a three-character extension).

For more details, see the MSI docs for this data type.

Examples

// Valid:
assert!(msi::Category::Cabinet.validate("hello.txt"));
assert!(msi::Category::Cabinet.validate("#HelloWorld"));
// Invalid:
assert!(!msi::Category::Cabinet.validate("longfilename.long"));
assert!(!msi::Category::Cabinet.validate("#123.456"));
§

Shortcut

A string that refers to a shortcut.

For more details, see the MSI docs for this data type.

Implementations§

source§

impl Category

source

pub fn validate(&self, string: &str) -> bool

Returns true if the given string is valid to store in a database column with this category.

Trait Implementations§

source§

impl Clone for Category

source§

fn clone(&self) -> Category

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Category

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Category

source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl FromStr for Category

§

type Err = Error

The associated error which can be returned from parsing.
source§

fn from_str(string: &str) -> Result<Category>

Parses a string s to return a value of this type. Read more
source§

impl Hash for Category

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Category

source§

fn eq(&self, other: &Category) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Category

source§

impl Eq for Category

source§

impl StructuralEq for Category

source§

impl StructuralPartialEq for Category

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.