1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
// This file is part of feed. // // Copyright © 2015-2017 Chris Palmer <pennstate5013@gmail.com> // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. //! The fields can be set for guid by using the methods under `GuidBuilder`. use GuidBuilder; use rss::Guid; impl GuidBuilder { /// Construct a new `GuidBuilder` and return default values. /// /// # Examples /// /// ``` /// use feed::GuidBuilder; /// /// let guid_builder = GuidBuilder::new(); /// ``` pub fn new() -> GuidBuilder { GuidBuilder::default() } /// Set the optional permalink that exists under `Guid`. /// /// # Examples /// /// ``` /// use feed::GuidBuilder; /// /// let mut guid_builder = GuidBuilder::new(); /// guid_builder.is_permalink(Some(false)); /// ``` pub fn is_permalink(&mut self, is_permalink: Option<bool>) -> &mut GuidBuilder { self.is_permalink = is_permalink; self } /// Set the guid that exists under `Guid`. /// /// # Examples /// /// ``` /// use feed::GuidBuilder; /// /// let mut guid_builder = GuidBuilder::new(); /// guid_builder.value("9DE46946-2F90-4D5D-9047-7E9165C16E7C"); /// ``` pub fn value(&mut self, value: &str) -> &mut GuidBuilder { self.value = value.to_owned(); self } /// Construct the `Guid` from the `GuidBuilder`. /// /// # Examples /// /// ``` /// use feed::GuidBuilder; /// /// let guid = GuidBuilder::new() /// .value("9DE46946-2F90-4D5D-9047-7E9165C16E7C") /// .is_permalink(Some(true)) /// .finalize(); /// ``` pub fn finalize(&self) -> Result<Guid, String> { let is_permalink = match self.is_permalink { Some(val) => val, None => true, }; Ok(Guid { is_permalink: is_permalink, value: self.value.clone(), }) } }