Skip to main content

Region

Enum Region 

Source
pub enum Region {
    UsEast1,
    UsEast2,
    UsWest2,
    EuWest1,
    ApNortheast1,
    Unlisted(String),
}
Expand description

An AWS region, closed over the five that run MicroVMs plus a named escape hatch.

See the module docs for why the five are an enum. Region::Unlisted is deliberately a variant rather than a hidden flag: a reader of a call site can see that someone opted into the trap, and a match over regions cannot forget the case exists.

Variants§

§

UsEast1

§

UsEast2

§

UsWest2

§

EuWest1

§

ApNortheast1

§

Unlisted(String)

A region this client has not seen carry MicroVMs.

You are opting into the null-message trap. If this region does not run MicroVMs, the first control-plane call answers AccessDeniedException with a null message and you will spend the next hour reading an IAM policy that is correct. Constructible only through Region::unlisted, which says so at the call site.

It exists because AWS adds regions faster than this list is re-read, and a client that refuses a region AWS has just launched in is its own kind of wrong. The override costs exactly the diagnostic above.

Implementations§

Source§

impl Region

Source

pub fn as_str(&self) -> &str

The wire spelling, which is also the endpoint’s middle segment.

Source

pub fn unlisted(name: impl Into<String>) -> Region

Opts into a region this client has not seen carry MicroVMs.

This is the escape hatch, and it costs you the diagnostic. If the region does not run MicroVMs, the first control-plane call answers AccessDeniedException with a null message field, which reads as a genuine IAM denial (docs/PLATFORM.md, “Calling an unpriced region returns AccessDeniedException with a null message”). Use it when AWS has launched MicroVMs somewhere new, and add the region to MICROVM_REGIONS in the same change.

A supported name passed here comes back as its proper variant rather than as Region::Unlisted, so unlisted("us-east-1") == Region::UsEast1 and nothing downstream has to handle two spellings of one region.

Source

pub fn is_supported(&self) -> bool

Whether this is one of the five, rather than an opted-into unlisted name.

Source

pub fn from_env(env: &dyn Fn(&str) -> Option<String>) -> Result<Region, Error>

The region the environment names: $AWS_REGION, then $AWS_DEFAULT_REGION, then us-east-1.

Parsed rather than accepted: an environment variable is a string, and this is the boundary where the enum cannot help. A region the client has not seen carry MicroVMs is refused with the null-message finding attached; opting in is explicit at a call site (--unlisted-region in the CLI, Region.unlisted in the bindings). env is a lookup rather than std::env::var so a caller (and a test) decides where the variables come from. The CLI’s region resolution and microvms_core::preflight::preflight both read it here.

Trait Implementations§

Source§

impl Clone for Region

Source§

fn clone(&self) -> Region

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Region

Source§

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

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

impl Display for Region

Source§

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

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

impl Eq for Region

Source§

impl FromStr for Region

Source§

fn from_str(name: &str) -> Result<Region, Error>

Parses one of the five, and refuses everything else.

The refusal is the point: this is the boundary a region name arrives at from a CLI flag or an environment variable, where it is still a string and the enum cannot help. A caller who genuinely wants a sixth region reaches for Region::unlisted and says so.

Source§

type Err = Error

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

impl Hash for Region

Source§

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

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 Region

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Region

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

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

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.