You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lolistealer/src/loli/mod.rs

29 lines
691 B

pub mod error;
pub mod encoding;
/// Attempt to decode an image
pub fn decode<S, W>(input: S, mut output: W) -> Result<usize, error::Error>
where S: AsRef<[u8]>,
W: AsMut<[u8]>
{
let input_bytes = input.as_ref();
let output_bytes = output.as_mut();
Ok(base64::decode_config_slice(input_bytes, base64::STANDARD, output_bytes)?)
}
/// Calculate the size for a base64 inpue
pub fn calc_size<T>(input: T) -> usize
where T: AsRef<[u8]>
{
encoding::data_size(input.as_ref().len())
}
/// Try to get the image format from a `str` slice.
pub fn attempt_get_format<T>(input: T) -> Result<encoding::ImageType, error::Error>
where T: AsRef<str>
{
input.as_ref().parse()
}