From 57e653e384f5c588eb6c512b967b9e3f22ac12a1 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 9 Jun 2016 19:39:17 +0200 Subject: [PATCH] Impl RefFlags::into_toml() as Into for RefFlags --- libimagref/src/flags.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/libimagref/src/flags.rs b/libimagref/src/flags.rs index 1dbbbd3f..17ff9fc7 100644 --- a/libimagref/src/flags.rs +++ b/libimagref/src/flags.rs @@ -32,13 +32,6 @@ impl RefFlags { }) } - /// Build a TOML::Value from this RefFlags object. - /// - /// Returns a Map which should be set in `ref.flags` in the header. - pub fn into_toml(self) -> Result { - unimplemented!() - } - /// Alias for `RefFlags::content_hashing()` pub fn is_often_moving(mut self, b: bool) -> RefFlags { self.with_content_hashing(b) @@ -64,3 +57,17 @@ impl RefFlags { } +impl Into for RefFlags { + + /// Build a TOML::Value from this RefFlags object. + /// + /// Returns a Map which should be set in `ref.flags` in the header. + fn into(self) -> Value { + let mut btm = BTreeMap::new(); + btm.insert(String::from("content_hashing"), Value::Boolean(self.content_hashing)); + btm.insert(String::from("permission_tracking"), Value::Boolean(self.permission_tracking)); + return Value::Table(btm) + } + +} +