LCOV - code coverage report
Current view: top level - libs/utils/src - toml_edit_ext.rs (source / functions) Coverage Total Hit
Test: 12c2fc96834f59604b8ade5b9add28f1dce41ec6.info Lines: 83.3 % 12 10
Test Date: 2024-07-03 15:33:13 Functions: 20.0 % 5 1

            Line data    Source code
       1            0 : #[derive(Debug, thiserror::Error)]
       2              : pub enum Error {
       3              :     #[error("item is not a document")]
       4              :     ItemIsNotADocument,
       5              :     #[error(transparent)]
       6              :     Serde(toml_edit::de::Error),
       7              : }
       8              : 
       9           24 : pub fn deserialize_item<T>(item: &toml_edit::Item) -> Result<T, Error>
      10           24 : where
      11           24 :     T: serde::de::DeserializeOwned,
      12           24 : {
      13           24 :     let document: toml_edit::Document = match item {
      14           16 :         toml_edit::Item::Table(toml) => toml.clone().into(),
      15            8 :         toml_edit::Item::Value(toml_edit::Value::InlineTable(toml)) => {
      16            8 :             toml.clone().into_table().into()
      17              :         }
      18            0 :         _ => return Err(Error::ItemIsNotADocument),
      19              :     };
      20              : 
      21           24 :     toml_edit::de::from_document(document).map_err(Error::Serde)
      22           24 : }
        

Generated by: LCOV version 2.1-beta