LCOV - code coverage report
Current view: top level - libs/utils/src - toml_edit_ext.rs (source / functions) Coverage Total Hit
Test: 5445d246133daeceb0507e6cc0797ab7c1c70cb8.info Lines: 81.8 % 11 9
Test Date: 2025-03-12 18:05:02 Functions: 50.0 % 2 1

            Line data    Source code
       1              : #[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            0 : }
        

Generated by: LCOV version 2.1-beta