multibucket 0.1.1

A unified async object-storage trait with a from-scratch Qiniu Kodo backend (upload / download / delete / stat / list / signed URLs).
Documentation
//! Qiniu regions and their service hosts.
//!
//! Hosts follow the Qiniu domain convention (upload on `*.qiniup.com`,
//! management/list/download on `*.qiniucs.com`). Every host can be overridden
//! in [`QiniuConfig`](super::QiniuConfig) — for example to route around a
//! locally-resolved IP or a private gateway — so a wrong default never blocks
//! an integration. The authoritative per-bucket hosts can always be confirmed
//! via `GET https://uc.qiniup.com/query?ak=<AccessKey>&bucket=<Bucket>`.

/// A Qiniu Kodo region.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub enum Region {
    /// 华东 - 杭州 (z0)
    #[default]
    Z0,
    /// 华北 - 淄博 (z1)
    Z1,
    /// 华南 - 广州 (z2)
    Z2,
    /// 北美 - 洛杉矶 (na0)
    Na0,
    /// 亚太 - 新加坡 (as0)
    As0,
    /// 华东 - 浙江 2 (ea0)
    Ea0,
}

impl Region {
    /// Qiniu region short id (`z0`, `z1`, ...).
    pub fn id(self) -> &'static str {
        match self {
            Region::Z0 => "z0",
            Region::Z1 => "z1",
            Region::Z2 => "z2",
            Region::Na0 => "na0",
            Region::As0 => "as0",
            Region::Ea0 => "ea0",
        }
    }

    /// Upload source host (`up*.qiniup.com`).
    pub fn up_host(self) -> &'static str {
        match self {
            Region::Z0 => "up.qiniup.com",
            Region::Z1 => "up-z1.qiniup.com",
            Region::Z2 => "up-z2.qiniup.com",
            Region::Na0 => "up-na0.qiniup.com",
            Region::As0 => "up-as0.qiniup.com",
            Region::Ea0 => "up-east2.qiniup.com",
        }
    }

    /// Resource-management host (`rs.*.qiniucs.com`): stat / delete / copy.
    pub fn rs_host(self) -> &'static str {
        match self {
            Region::Z0 => "rs.z0.qiniucs.com",
            Region::Z1 => "rs.z1.qiniucs.com",
            Region::Z2 => "rs.z2.qiniucs.com",
            Region::Na0 => "rs.na0.qiniucs.com",
            Region::As0 => "rs.as0.qiniucs.com",
            Region::Ea0 => "rs.ea0.qiniucs.com",
        }
    }

    /// Listing host (`rsf.*.qiniucs.com`).
    pub fn rsf_host(self) -> &'static str {
        match self {
            Region::Z0 => "rsf.z0.qiniucs.com",
            Region::Z1 => "rsf.z1.qiniucs.com",
            Region::Z2 => "rsf.z2.qiniucs.com",
            Region::Na0 => "rsf.na0.qiniucs.com",
            Region::As0 => "rsf.as0.qiniucs.com",
            Region::Ea0 => "rsf.ea0.qiniucs.com",
        }
    }

    /// Default download host (`io.*.qiniucs.com`), used when the bucket has no
    /// custom download domain configured.
    pub fn io_host(self) -> &'static str {
        match self {
            Region::Z0 => "io.z0.qiniucs.com",
            Region::Z1 => "io.z1.qiniucs.com",
            Region::Z2 => "io.z2.qiniucs.com",
            Region::Na0 => "io.na0.qiniucs.com",
            Region::As0 => "io.as0.qiniucs.com",
            Region::Ea0 => "io.ea0.qiniucs.com",
        }
    }
}