fix compile warnings

This commit is contained in:
blek 2023-10-27 01:19:30 +10:00
parent 0efb0f5771
commit e81a5e3ec3
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 4 additions and 2 deletions

View File

@ -6,7 +6,7 @@
use std::{collections::HashMap, net::IpAddr};
use askama::Template;
use warp::{Filter, reply::{Reply, json, with_status, html}, reject::Rejection, filters::multipart::FormData, http::StatusCode};
use warp::{Filter, reply::{Reply, with_status, html}, reject::Rejection, filters::multipart::FormData, http::StatusCode};
use futures_util::TryStreamExt;
use bytes::BufMut;
use serde::Serialize;
@ -14,7 +14,7 @@ use warp_real_ip::real_ip;
use crate::files::{File, lookup::LookupKind, DeleteMode};
use super::{state::SharedState, pages::{BadActionReq, UploadSuccessPage, self, ErrorPage}, rejection::HttpReject};
use super::{state::SharedState, pages::{UploadSuccessPage, ErrorPage}, rejection::HttpReject};
#[derive(Debug, Serialize, Clone)]
struct FormElement {
@ -22,6 +22,8 @@ struct FormElement {
mime: String
}
impl FormElement {
#[allow(dead_code)]
pub fn as_str_or_reject(self: &Self) -> Result<String, Rejection> {
Ok(String::from_utf8(self.data.clone()).map_err(|err| warp::reject::custom(HttpReject::FromUtf8Error(err)))?)
}