pub fn search_for_names(
    deps: Deps<ProvenanceQuery>,
    search: String,
) -> Result<Binary, ContractError> {
    let meta_storage = meta_read(deps.storage);
    let search_str = search.as_str();
    let names = meta_storage
        .range(None, None, Order::Ascending)
        .into_iter()
        .filter(|element| element.is_ok())
        .map(|element| element.unwrap().1)
        .filter(|name_meta| name_meta.name.contains(search_str))
        .take(MAX_NAME_SEARCH_RESULTS)
        .collect();
    to_binary(&NameSearchResponse {
        search: search.clone(),
        names,
    })
    .map_err(ContractError::Std)
}
/// Scans the entire storage for the target name string by doing direct matches.
/// Will only ever return a maximum of MAX_NAME_SEARCH_RESULTS.
Scans the entire storage for the target name string by doing direct matches.
Will only ever return a maximum of MAX_NAME_SEARCH_RESULTS.
Scans the entire storage for the target name string by doing direct matches . Will only ever return a maximum of MAX_NAME_SEARCH_RESULTS .
pub fn search_for_names(
    deps: Deps<ProvenanceQuery>,
    search: String,
) -> Result<Binary, ContractError> {
    let meta_storage = meta_read(deps.storage);
    let search_str = search.as_str();
    let names = meta_storage
        .range(None, None, Order::Ascending)
        .into_iter()
        .filter(|element| element.is_ok())
        .map(|element| element.unwrap().1)
        .filter(|name_meta| name_meta.name.contains(search_str))
        .take(MAX_NAME_SEARCH_RESULTS)
        .collect();
    to_binary(&NameSearchResponse {
        search: search.clone(),
        names,
    })
    .map_err(ContractError::Std)
}
pub fn search_for_names ( deps : Deps < ProvenanceQuery > , search : String , ) -> Result < Binary , ContractError > { let meta_storage = meta_read ( deps . storage ) ; let search_str = search . as_str ( ) ; let names = meta_storage . range ( None , None , Order :: Ascending ) . into_iter ( ) . filter ( | element | element . is_ok ( ) ) . map ( | element | element . unwrap ( ) . 1 ) . filter ( | name_meta | name_meta . name . contains ( search_str ) ) . take ( MAX_NAME_SEARCH_RESULTS ) . collect ( ) ; to_binary ( & NameSearchResponse { search : search . clone ( ) , names , } ) . map_err ( ContractError :: Std ) }
Scans the entire storage for the target name string by doing direct matches.
Scans the entire storage for the target name string by doing direct matches .
deps
Deps<ProvenanceQuery>
search
String