async fn parcel_in_bindle<P: Provider + Sync>(
        store: &P,
        bindle_id: &str,
        sha: &str,
    ) -> std::result::Result<crate::Label, warp::reply::WithStatus<crate::server::reply::Toml>>
    {
        let inv = match store.get_invoice(bindle_id).await {
            Ok(i) => i,
            Err(e) => return Err(reply::into_reply(e)),
        };

        // Make sure the sha exists in the list
        let label = inv
            .parcel
            .map(|parcels| parcels.into_iter().find(|p| p.label.sha256 == sha))
            .flatten()
            .map(|p| p.label);

        match label {
            Some(l) => Ok(l),
            None => Err(reply::reply_from_error(
                format!("Parcel SHA {} does not exist in invoice {}", sha, bindle_id),
                warp::http::StatusCode::BAD_REQUEST,
            )),
        }
    }
/// Fetches an invoice from the given store and checks that the given SHA exists within that
/// invoice. Returns a result where the Error variant is a warp reply containing the error
Fetches an invoice from the given store and checks that the given SHA exists within that
invoice. Returns a result where the Error variant is a warp reply containing the error
Fetches an invoice from the given store and checks that the given SHA exists within that invoice . Returns a result where the Error variant is a warp reply containing the error
async fn parcel_in_bindle<P: Provider + Sync>(
        store: &P,
        bindle_id: &str,
        sha: &str,
    ) -> std::result::Result<crate::Label, warp::reply::WithStatus<crate::server::reply::Toml>>
    {
        let inv = match store.get_invoice(bindle_id).await {
            Ok(i) => i,
            Err(e) => return Err(reply::into_reply(e)),
        };
        // Make sure the sha exists in the list
        let label = inv
            .parcel
            .map(|parcels| parcels.into_iter().find(|p| p.label.sha256 == sha))
            .flatten()
            .map(|p| p.label);
        match label {
            Some(l) => Ok(l),
            None => Err(reply::reply_from_error(
                format!("Parcel SHA {} does not exist in invoice {}", sha, bindle_id),
                warp::http::StatusCode::BAD_REQUEST,
            )),
        }
    }
async fn parcel_in_bindle < P : Provider + Sync > ( store : & P , bindle_id : & str , sha : & str , ) -> std :: result :: Result < crate :: Label , warp :: reply :: WithStatus < crate :: server :: reply :: Toml > > { let inv = match store . get_invoice ( bindle_id ) . await { Ok ( i ) => i , Err ( e ) => return Err ( reply :: into_reply ( e ) ) , } ; // Make sure the sha exists in the list let label = inv . parcel . map ( | parcels | parcels . into_iter ( ) . find ( | p | p . label . sha256 == sha ) ) . flatten ( ) . map ( | p | p . label ) ; match label { Some ( l ) => Ok ( l ) , None => Err ( reply :: reply_from_error ( format ! ( " " sha bindle_id ) , warp :: http :: StatusCode :: BAD_REQUEST , ) ) , } }
Fetches an invoice from the given store and checks that the given SHA exists within that
invoice.
Fetches an invoice from the given store and checks that the given SHA exists within that invoice .
store
&P
bindle_id
&str
sha
&str
store
&P
bindle_id
&str
sha
&str