diff --git a/rust-bindings/rust/src/object_name.rs b/rust-bindings/rust/src/object_name.rs index 25635ec7..5d614490 100644 --- a/rust-bindings/rust/src/object_name.rs +++ b/rust-bindings/rust/src/object_name.rs @@ -1,6 +1,7 @@ use functions::{object_name_deserialize, object_name_serialize, object_to_string}; use glib; use glib::translate::*; +use glib::GString; use glib_sys; use ostree_sys; use std::fmt::Display; @@ -17,8 +18,7 @@ fn hash_object_name(v: &glib::Variant) -> u32 { #[derive(Eq, Debug)] pub struct ObjectName { variant: glib::Variant, - // TODO: can I store a GString here? - checksum: String, + checksum: GString, object_type: ObjectType, } @@ -27,12 +27,12 @@ impl ObjectName { let deserialize = object_name_deserialize(&variant); ObjectName { variant, - checksum: deserialize.0.into(), + checksum: deserialize.0, object_type: deserialize.1, } } - pub fn new>(checksum: S, object_type: ObjectType) -> ObjectName { + pub fn new>(checksum: S, object_type: ObjectType) -> ObjectName { let checksum = checksum.into(); let variant = object_name_serialize(checksum.as_str(), object_type).unwrap(); ObjectName { @@ -43,18 +43,16 @@ impl ObjectName { } pub fn checksum(&self) -> &str { - self.checksum.as_ref() + self.checksum.as_str() } pub fn object_type(&self) -> ObjectType { self.object_type } - // TODO: return GString - pub fn name(&self) -> String { + pub fn name(&self) -> GString { object_to_string(self.checksum(), self.object_type()) .expect("type checks should make this safe") - .into() } }