From ab3e2c908e1c25494e5849b3578f15617beea22b Mon Sep 17 00:00:00 2001 From: Felix Krull Date: Tue, 21 May 2019 20:29:42 +0200 Subject: [PATCH] Switch ObjectName to GString --- rust-bindings/rust/src/object_name.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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() } }