docs: add more
This commit is contained in:
parent
1d408d443b
commit
8f7de9824b
|
@ -1,3 +1,5 @@
|
||||||
|
//! Data center types
|
||||||
|
|
||||||
use errors::UnknownVariant;
|
use errors::UnknownVariant;
|
||||||
|
|
||||||
use std::fmt::{Display, Formatter, Result as FmtResult};
|
use std::fmt::{Display, Formatter, Result as FmtResult};
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
|
//! Error types (non-FFXIV)
|
||||||
|
|
||||||
use std::fmt::{Display, Formatter, Result as FmtResult};
|
use std::fmt::{Display, Formatter, Result as FmtResult};
|
||||||
|
|
||||||
|
/// An error representing an unknown variant of any `enum`.
|
||||||
|
///
|
||||||
|
/// `(enum name, unknown variant)`, e.g. `("DataCenter", "my invalid input")`
|
||||||
|
///
|
||||||
|
/// This is generally encountered when using [`FromStr`] on any `enum` in this crate.
|
||||||
|
///
|
||||||
|
/// [`FromStr`]: ::std::str::FromStr
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct UnknownVariant(pub &'static str, pub String);
|
pub struct UnknownVariant(
|
||||||
|
/// The `enum` name (e.g. `"DataCenter"`)
|
||||||
|
pub &'static str,
|
||||||
|
/// The unknown variant given
|
||||||
|
pub String
|
||||||
|
);
|
||||||
|
|
||||||
impl Display for UnknownVariant {
|
impl Display for UnknownVariant {
|
||||||
fn fmt(&self, f: &mut Formatter) -> FmtResult {
|
fn fmt(&self, f: &mut Formatter) -> FmtResult {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
//! Types for use in FFXIV-related projects.
|
||||||
|
|
||||||
pub mod data_centers;
|
pub mod data_centers;
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
pub mod jobs;
|
pub mod jobs;
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
|
//! Job role types
|
||||||
|
|
||||||
use errors::UnknownVariant;
|
use errors::UnknownVariant;
|
||||||
|
|
||||||
use std::fmt::{Display, Formatter, Result as FmtResult};
|
use std::fmt::{Display, Formatter, Result as FmtResult};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
/// The roles available in the game.
|
||||||
|
///
|
||||||
|
/// Each [Job] has a role attached to it.
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum Role {
|
pub enum Role {
|
||||||
Dps,
|
Dps,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
//! World types
|
||||||
|
|
||||||
use data_centers::DataCenter;
|
use data_centers::DataCenter;
|
||||||
use errors::UnknownVariant;
|
use errors::UnknownVariant;
|
||||||
|
|
||||||
|
@ -6,7 +8,7 @@ use std::str::FromStr;
|
||||||
|
|
||||||
/// The worlds, sometimes called servers, in the game.
|
/// The worlds, sometimes called servers, in the game.
|
||||||
///
|
///
|
||||||
/// Each [Data Center] has multiple worlds attached to it.
|
/// Each [`DataCenter`] has multiple worlds attached to it.
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum World {
|
pub enum World {
|
||||||
// Aether
|
// Aether
|
||||||
|
@ -169,6 +171,7 @@ impl World {
|
||||||
World::Ultros,
|
World::Ultros,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/// Returns the string variant of this world.
|
||||||
pub fn as_str(&self) -> &'static str {
|
pub fn as_str(&self) -> &'static str {
|
||||||
match *self {
|
match *self {
|
||||||
World::Adamantoise => "Adamantoise",
|
World::Adamantoise => "Adamantoise",
|
||||||
|
@ -245,6 +248,7 @@ impl World {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the [`DataCenter`] this world is on.
|
||||||
pub fn data_center(&self) -> DataCenter {
|
pub fn data_center(&self) -> DataCenter {
|
||||||
match *self {
|
match *self {
|
||||||
World::Adamantoise |
|
World::Adamantoise |
|
||||||
|
@ -325,6 +329,9 @@ impl World {
|
||||||
impl FromStr for World {
|
impl FromStr for World {
|
||||||
type Err = UnknownVariant;
|
type Err = UnknownVariant;
|
||||||
|
|
||||||
|
/// Parses a string `s` to return a value of this type.
|
||||||
|
///
|
||||||
|
/// This is case-insensitive.
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
let world = match s.to_lowercase().as_str() {
|
let world = match s.to_lowercase().as_str() {
|
||||||
"adamantoise" => World::Adamantoise,
|
"adamantoise" => World::Adamantoise,
|
||||||
|
|
Loading…
Reference in New Issue