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
Wrap a Service in a PrincipalIdentity.
impl From<Service> for PrincipalIdentity
Wrap a Service in a PrincipalIdentity.
Source§impl Ord for Service
impl Ord for Service
Source§impl PartialOrd for Service
impl PartialOrd for Service
impl Eq for Service
impl StructuralPartialEq for Service
Auto Trait Implementations§
impl Freeze for Service
impl RefUnwindSafe for Service
impl Send for Service
impl Sync for Service
impl Unpin for Service
impl UnwindSafe for Service
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
Mutably borrows from an owned value. Read more