LCOV - code coverage report
Current view: top level - libs/utils/src - toml_edit_ext.rs (source / functions) Coverage Total Hit
Test: fc67f8dc6087a0b4f4f0bcd74f6e1dc25fab8cf3.info Lines: 83.3 % 12 10
Test Date: 2024-09-24 13:57:57 Functions: 25.0 % 4 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           10 : pub fn deserialize_item<T>(item: &toml_edit::Item) -> Result<T, Error>
      10           10 : where
      11           10 :     T: serde::de::DeserializeOwned,
      12           10 : {
      13           10 :     let document: toml_edit::DocumentMut = match item {
      14            9 :         toml_edit::Item::Table(toml) => toml.clone().into(),
      15            1 :         toml_edit::Item::Value(toml_edit::Value::InlineTable(toml)) => {
      16            1 :             toml.clone().into_table().into()
      17              :         }
      18            0 :         _ => return Err(Error::ItemIsNotADocument),
      19              :     };
      20              : 
      21           10 :     toml_edit::de::from_document(document).map_err(Error::Serde)
      22           10 : }
        

Generated by: LCOV version 2.1-beta