1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
// slug string A human-readable string that is used to uniquely identify each size. // available boolean This is a boolean value that represents whether new Droplets can be created with this size. // transfer number The amount of transfer bandwidth that is available for Droplets created in this size. This only counts traffic on the public interface. The value is given in terabytes. // price_monthly number This attribute describes the monthly cost of this Droplet size if the Droplet is kept for an entire month. The value is measured in US dollars. // price_hourly number This describes the price of the Droplet size as measured hourly. The value is measured in US dollars. // memory number The amount of RAM allocated to Droplets created of this size. The value is represented in megabytes. // vcpus number The number of virtual CPUs allocated to Droplets of this size. // disk number The amount of disk space set aside for Droplets of this size. The value is represented in gigabytes. // regions array An array containing the region slugs where this size is available for Droplet creates. use std::fmt; use std::borrow::Cow; use response::NamedResponse; use response; #[derive(Deserialize, Debug)] pub struct Size { slug: String, memory: f64, vcpus: f64, disk: f64, transfer: f64, price_monthly: f64, price_hourly: f64, regions: Vec<String>, available: bool, } impl response::NotArray for Size {} impl fmt::Display for Size { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Slug: {}\n\ Available: {}\n\ Transfer Bandwidth: {} TB\n\ Monthly Price: ${}\n\ Hourly Price: ${}\n\ Memory: {} MB\n\ Virtual CPUs: {:.0}\n\ Disk Space: {} GB\n\ Sizes: {}", self.slug, self.available, self.transfer, self.price_monthly, self.price_hourly, self.memory, self.vcpus, self.disk, self.regions.iter().fold(String::new(), |acc, s| acc + &format!(" {},", s)[..])) } } impl NamedResponse for Size { fn name<'a>() -> Cow<'a, str> { "size".into() } } pub type Sizes = Vec<Size>;