openapi-nexus 0.1.16

OpenAPI 3.x multi-language code generator
Documentation
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct UploadFile {
    pub data: Vec<u8>,
    pub filename: Option<String>,
}

impl UploadFile {
    pub fn new(data: impl Into<Vec<u8>>, filename: impl Into<String>) -> Self {
        Self {
            data: data.into(),
            filename: Some(filename.into()),
        }
    }

    pub fn from_bytes(data: impl Into<Vec<u8>>) -> Self {
        Self {
            data: data.into(),
            filename: None,
        }
    }

    pub fn filename_or_default<'a>(&'a self, default_name: &'a str) -> &'a str {
        self.filename.as_deref().unwrap_or(default_name)
    }
}

pub fn multipart_header_value(value: &str) -> String {
    value
        .replace('\r', "")
        .replace('\n', "")
        .replace('\\', "\\\\")
        .replace('"', "\\\"")
}