move core::pdu and core::state_res into core::matrix::
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
4e5b87d0cd
commit
532dfd004d
91 changed files with 266 additions and 205 deletions
src/core/matrix/pdu
20
src/core/matrix/pdu/content.rs
Normal file
20
src/core/matrix/pdu/content.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
use serde::Deserialize;
|
||||
use serde_json::value::Value as JsonValue;
|
||||
|
||||
use crate::{Result, err, implement};
|
||||
|
||||
#[must_use]
|
||||
#[implement(super::Pdu)]
|
||||
pub fn get_content_as_value(&self) -> JsonValue {
|
||||
self.get_content()
|
||||
.expect("pdu content must be a valid JSON value")
|
||||
}
|
||||
|
||||
#[implement(super::Pdu)]
|
||||
pub fn get_content<T>(&self) -> Result<T>
|
||||
where
|
||||
T: for<'de> Deserialize<'de>,
|
||||
{
|
||||
serde_json::from_str(self.content.get())
|
||||
.map_err(|e| err!(Database("Failed to deserialize pdu content into type: {e}")))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue