Serialize to the text wire format.
(&self)
| 143 | |
| 144 | /// Serialize to the text wire format. |
| 145 | pub fn to_text(&self) -> String { |
| 146 | let scope = if self.scope.is_draft() { |
| 147 | "draft" |
| 148 | } else { |
| 149 | "shared" |
| 150 | }; |
| 151 | let parent = self.parent.as_deref().unwrap_or(NONE_FIELD); |
| 152 | let state = if self.changes.is_empty() { |
| 153 | NONE_FIELD.to_string() |
| 154 | } else { |
| 155 | self.state.to_base32() |
| 156 | }; |
| 157 | |
| 158 | let mut out = format!("{}\t{}\t{}\t{}\n", self.name, scope, parent, state); |
| 159 | for hash in &self.changes { |
| 160 | out.push_str(&hash.to_base32()); |
| 161 | out.push('\n'); |
| 162 | } |
| 163 | out |
| 164 | } |
| 165 | |
| 166 | /// Parse the text wire format. |
| 167 | /// |