You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: search_response_rest.rs
    path of file: ./repos/quickwit/quickwit/quickwit-search/src
    
    the code of the file until where you have to start completion: // Copyright (C) 2024 Quickwit, Inc.
//
// Quickwit is offered under the AGPL v3.0 and as commercial software.
// For commercial licensing, contact us at hello@quickwit.io.
//
// AGPL:
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without 
    
    fn try_from(search_response: SearchResponse) -> Result<Self, Self::Error> {
        let mut documents = Vec::with_capacity(search_response.hits.len());
        let mut snippets = Vec::new();
        for hit in search_response.hits {
            let document: JsonValue = serde_json::from_str(&hit.json).map_err(|err| {
                SearchError::Internal(format!(
                    "failed to serialize document `{}` to JSON: `{}`",
                    truncate_str(&hit.json, 100),
                    err
                ))
            })?;
            documents.push(document);

            if let Some(snippet_json) = hit.snippet {
                let snippet_opt: JsonValue =
                    serde_json::from_str(&snippet_json).map_err(|err| {
                        SearchError::Internal(format!(
                            "failed to serialize snippet `{snippet_json}` to JSON: `{err}`"
                        ))
                    })?;
                snippets.push(snippet_opt);
            }
        }

        let snippet_opt = if !snippets.is_empty() {
            Some(snippets)
        } else {
            None
        };

        let aggregations_opt = if let Some(aggregation_json) = search_response.aggregation {
            let aggregation: JsonValue = serde_json::from_str(&aggregation_json)
                .map_err(|err| SearchError::Internal(err.to_string()))?;
            Some(aggregation)
        } else {
            None
        };

        Ok(SearchResponseRest {
            num_hits: search_response.num_hits,
            hits: documents,
            snippets: snippet_opt,
            elapsed_time_micros: search_response.elapsed_time_micros,
            errors: search_response.errors,
            aggregations: aggregations_opt,
        })
    }