pub struct ShopDomain { /* private fields */ }Expand description
A validated Shopify shop domain.
This newtype validates and normalizes shop domains to the full
shop.myshopify.com format.
§Accepted Formats
shop-name- normalized toshop-name.myshopify.comshop-name.myshopify.com- used as-is
§Serialization
ShopDomain serializes to and deserializes from the full domain string:
use shopify_sdk::ShopDomain;
let domain = ShopDomain::new("my-store").unwrap();
let json = serde_json::to_string(&domain).unwrap();
assert_eq!(json, r#""my-store.myshopify.com""#);§Example
use shopify_sdk::ShopDomain;
// Short format is normalized
let domain = ShopDomain::new("my-store").unwrap();
assert_eq!(domain.as_ref(), "my-store.myshopify.com");
assert_eq!(domain.shop_name(), "my-store");
// Full format is accepted
let domain = ShopDomain::new("my-store.myshopify.com").unwrap();
assert_eq!(domain.as_ref(), "my-store.myshopify.com");Implementations§
Source§impl ShopDomain
impl ShopDomain
Sourcepub fn new(domain: impl Into<String>) -> Result<Self, ConfigError>
pub fn new(domain: impl Into<String>) -> Result<Self, ConfigError>
Creates a new validated shop domain.
§Errors
Returns ConfigError::InvalidShopDomain if the domain is invalid.
Trait Implementations§
Source§impl AsRef<str> for ShopDomain
impl AsRef<str> for ShopDomain
Source§impl Clone for ShopDomain
impl Clone for ShopDomain
Source§fn clone(&self) -> ShopDomain
fn clone(&self) -> ShopDomain
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ShopDomain
impl Debug for ShopDomain
Source§impl<'de> Deserialize<'de> for ShopDomain
impl<'de> Deserialize<'de> for ShopDomain
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ShopDomain
impl PartialEq for ShopDomain
Source§impl Serialize for ShopDomain
impl Serialize for ShopDomain
impl Eq for ShopDomain
impl StructuralPartialEq for ShopDomain
Auto Trait Implementations§
impl Freeze for ShopDomain
impl RefUnwindSafe for ShopDomain
impl Send for ShopDomain
impl Sync for ShopDomain
impl Unpin for ShopDomain
impl UnwindSafe for ShopDomain
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
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
Compare self to
key and return true if they are equal.