use shareable::SharedObject;
use item_value::ItemValue;
use notify::Notify;
#[derive(Clone)]
pub struct StringValue
{
value : SharedObject<String>
}
impl StringValue
{
pub fn new() -> StringValue
{
StringValue {
value : SharedObject::new(String::from(""))
}
}
pub fn get(&self) -> String
{
String::from(self.value.get().as_str())
}
}
use std::fmt::{Debug, Display, Formatter, Error};
impl Debug for StringValue
{
fn fmt(
&self,
f : &mut Formatter
) -> Result<(), Error>
{
write!(f, "{:?}", self.get())
}
}
impl Display for StringValue
{
fn fmt(
&self,
f : &mut Formatter
) -> Result<(), Error>
{
write!(f, "{}", self.get())
}
}
impl Notify for StringValue
{
fn send(
&self,
value : &ItemValue
)
{
self.value.set(String::from(value.get_str()));
}
}