/// Parse a valid base64 padded string from the start of input.
Parse a valid base64 padded string from the start of input.
Parse a valid base64 padded string from the start of input .
pub(crate) fn base64(input: &str) -> IResult<&str, &str> {
    let base_res = take_while1(is_base64_body_char)(input)?;
    let remainder = base_res.1.len() % 4;
    let res = if remainder == 1 {
        return Err(nom::Err::Error(ParseError::from_error_kind(
            input,
            ErrorKind::TakeWhile1,
        )));
    } else if remainder == 2 || remainder == 3 {
        let data_char_len = base_res.1.len();
        recognizec(input, |i| {
            pairc(i, take(data_char_len), count(char('='), 4 - remainder))
        })?
    } else {
        base_res
    };
    if res.0.chars().next().map(|c| c.is_ascii_whitespace()) == Some(false) {
        is_a(" ")(res.0)?;
    }
    Ok(res)
}
pub ( crate ) fn base64 ( input : & str ) -> IResult < & str , & str > { let base_res = take_while1 ( is_base64_body_char ) ( input ) ? ; let remainder = base_res . 1 . len ( ) % 4 ; let res = if remainder == 1 { return Err ( nom :: Err :: Error ( ParseError :: from_error_kind ( input , ErrorKind :: TakeWhile1 , ) ) ) ; } else if remainder == 2 || remainder == 3 { let data_char_len = base_res . 1 . len ( ) ; recognizec ( input , | i | { pairc ( i , take ( data_char_len ) , count ( char ( '=' ) , 4 - remainder ) ) } ) ? } else { base_res } ; if res . 0 . chars ( ) . next ( ) . map ( | c | c . is_ascii_whitespace ( ) ) == Some ( false ) { is_a ( " " ) ( res . 0 ) ? ; } Ok ( res ) }
Parse a valid base64 padded string from the start of input.
Parse a valid base64 padded string from the start of input .
input
&str