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 can answer AccessDeniedException with a
null message, which an IAM denial can also produce. Constructible through
Region::unlisted, which makes that uncertainty visible 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
impl Region
Sourcepub fn unlisted(name: impl Into<String>) -> Region
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 can also mean an
IAM denial (docs/PLATFORM.md, “A null-message AccessDeniedException can mean
region availability or IAM”). 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.
Sourcepub fn is_supported(&self) -> bool
pub fn is_supported(&self) -> bool
Whether this is one of the five, rather than an opted-into unlisted name.
Sourcepub fn from_env(env: &dyn Fn(&str) -> Option<String>) -> Result<Region, Error>
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§
impl Eq for Region
Source§impl FromStr for Region
impl FromStr for Region
Source§fn from_str(name: &str) -> Result<Region, Error>
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.
impl StructuralPartialEq for Region
Auto Trait Implementations§
impl Freeze for Region
impl RefUnwindSafe for Region
impl Send for Region
impl Sync for Region
impl Unpin for Region
impl UnsafeUnpin for Region
impl UnwindSafe for Region
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.