api_versions

Macro api_versions 

Source
macro_rules! api_versions {
    ( [ $( (
        $major:literal,
        $name:ident
    ) ),* $(,)? ] ) => { ... };
}
Expand description

Helper macro used to define API versions

use dropshot_api_manager_types::{
    SupportedVersion, SupportedVersions, api_versions,
};

api_versions!([
    // Define the API versions here.
    (2, ADD_FOOBAR_OPERATION),
    (1, INITIAL),
]);

This example says that there are two API versions: 1.0.0 (the initial version) and 2.0.0 (which adds an operation called “foobar”). This macro invocation defines symbolic constants of type semver::Version for each of these, equivalent to:

pub const VERSION_ADD_FOOBAR_OPERATION: semver::Version =
    semver::Version::new(2, 0, 0);
pub const VERSION_INITIAL: semver::Version = semver::Version::new(1, 0, 0);

It also defines a function called pub fn supported_versions() -> SupportedVersions that, as the name suggests, returns a SupportedVersions that describes these two supported API versions.