diff --git a/Cargo.lock b/Cargo.lock index 2d8bb2c..627eb66 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -224,7 +224,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "forgejo-api-types" -version = "0.1.6" +version = "0.1.7" dependencies = [ "chrono", "clap", diff --git a/src/types/api/search_results.rs b/src/types/api/search_results.rs index 33084b8..9ec56c6 100644 --- a/src/types/api/search_results.rs +++ b/src/types/api/search_results.rs @@ -12,6 +12,16 @@ pub struct SearchResults { ok: IsOk, } +impl SearchResults { + /// converts the result data coming from the API into a rust native result + pub fn result(self) -> Result { + match self.ok { + IsOk::Yes => Ok(self.data), + IsOk::No => Err(self.data), + } + } +} + #[cfg(test)] mod search_results_tests { use crate::types::api::search_results::SearchResults;