(&self)
| 97 | |
| 98 | #[must_use] |
| 99 | pub fn to_json(&self) -> JsonValue { |
| 100 | let mut object = BTreeMap::new(); |
| 101 | object.insert( |
| 102 | "version".to_string(), |
| 103 | JsonValue::Number(i64::from(self.version)), |
| 104 | ); |
| 105 | object.insert( |
| 106 | "messages".to_string(), |
| 107 | JsonValue::Array( |
| 108 | self.messages |
| 109 | .iter() |
| 110 | .map(ConversationMessage::to_json) |
| 111 | .collect(), |
| 112 | ), |
| 113 | ); |
| 114 | JsonValue::Object(object) |
| 115 | } |
| 116 | |
| 117 | pub fn from_json(value: &JsonValue) -> Result<Self, SessionError> { |
| 118 | let object = value |
no test coverage detected