mirror of
https://github.com/ostreedev/ostree.git
synced 2024-12-22 17:35:55 +03:00
Switch ObjectName to GString
This commit is contained in:
parent
475cd53c43
commit
ab3e2c908e
@ -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<S: Into<String>>(checksum: S, object_type: ObjectType) -> ObjectName {
|
||||
pub fn new<S: Into<GString>>(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()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user