The main enums now have the ability to be displayed.

This commit is contained in:
Jason Travis Smith 2016-03-25 05:59:12 -04:00
parent d69f9b8e9b
commit 82486b1634
2 changed files with 119 additions and 0 deletions

View File

@ -38,3 +38,68 @@ pub enum TaskState
/// in an inproper state during its lifetime. /// in an inproper state during its lifetime.
Unknown Unknown
} }
impl TaskState
{
/// Get a str representation of this variant.
pub fn to_str(&self) -> &'static str
{
match *self
{
TaskState::Starting =>
{
"Starting"
}
TaskState::Waiting =>
{
"Waiting"
}
TaskState::DoneWaiting =>
{
"DoneWaiting"
}
TaskState::Processing =>
{
"Processing"
}
TaskState::Finished =>
{
"Finished"
}
TaskState::Unknown =>
{
"Unknown"
}
}
}
/// Get a String representation of this variant.
pub fn to_string(&self) -> String
{
String::from(self.to_str())
}
}
impl ::std::fmt::Debug for TaskState
{
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result
{
write!(f, "{}", self.to_str())
}
}
impl ::std::fmt::Display for TaskState
{
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result
{
write!(f, "{}", self.to_str())
}
}

View File

@ -14,3 +14,57 @@ pub enum ThreadState
/// ///
Finished Finished
} }
impl ThreadState
{
/// Get a str representation of this variant.
pub fn to_str(&self) -> &'static str
{
match *self
{
ThreadState::Starting =>
{
"Starting"
}
ThreadState::Idle =>
{
"Idle"
}
ThreadState::Processing =>
{
"Processing"
}
ThreadState::Finished =>
{
"Finished"
}
}
}
/// Get a String representation of this variant.
pub fn to_string(&self) -> String
{
String::from(self.to_str())
}
}
impl ::std::fmt::Debug for ThreadState
{
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result
{
write!(f, "{}", self.to_str())
}
}
impl ::std::fmt::Display for ThreadState
{
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result
{
write!(f, "{}", self.to_str())
}
}