Struct scratchstack_aws_principal::Service
source · pub struct Service { /* private fields */ }
Expand description
Details about an AWS or AWS-like service.
Service structs are immutable.
Implementations§
source§impl Service
impl Service
sourcepub fn new(
service_name: &str,
region: Option<String>,
dns_suffix: &str
) -> Result<Self, PrincipalError>
pub fn new(
service_name: &str,
region: Option<String>,
dns_suffix: &str
) -> Result<Self, PrincipalError>
Create a Service object representing an AWS(-ish) service.
Arguments
service_name
: The name of the service. This must meet the following requirements or a PrincipalError::InvalidService error will be returned:- The name must contain between 1 and 32 characters.
- The name must be composed to ASCII alphanumeric characters or one of
, - . = @ _
.
region
: The region the service is running in. IfNone
, the service is global.dns_suffix
: The DNS suffix of the service. This is usually amazonaws.com.
If all of the requirements are met, a Service object is returned. Otherwise, a PrincipalError error is returned.
Example
let service = Service::new("s3", Some("us-east-1".to_string()), "amazonaws.com").unwrap();
assert_eq!(service.service_name(), "s3");
assert_eq!(service.region(), Some("us-east-1"));
assert_eq!(service.dns_suffix(), "amazonaws.com");
assert_eq!(service.regional_dns_name(), "s3.us-east-1.amazonaws.com");
assert_eq!(service.global_dns_name(), "s3.amazonaws.com");
sourcepub fn service_name(&self) -> &str
pub fn service_name(&self) -> &str
The name of the service.
sourcepub fn region(&self) -> Option<&str>
pub fn region(&self) -> Option<&str>
The region of the service. If the service is global, this will be None
.
sourcepub fn dns_suffix(&self) -> &str
pub fn dns_suffix(&self) -> &str
The DNS suffix of the service.
sourcepub fn regional_dns_name(&self) -> String
pub fn regional_dns_name(&self) -> String
The regional DNS name of the service. If the service is global, this will be the same as the global DNS name.
sourcepub fn global_dns_name(&self) -> String
pub fn global_dns_name(&self) -> String
The global DNS name of the service (omitting the regional component, if any).
Trait Implementations§
source§impl From<Service> for PrincipalIdentity
impl From<Service> for PrincipalIdentity
Wrap a Service in a PrincipalIdentity.
source§impl Ord for Service
impl Ord for Service
source§impl PartialEq<Service> for Service
impl PartialEq<Service> for Service
source§impl PartialOrd<Service> for Service
impl PartialOrd<Service> for Service
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more