pub fn encode_config_slice<T: AsRef<[u8]>>(input: T, config: Config, output: &mut [u8]) -> usize {
    let input_bytes = input.as_ref();

    let encoded_size = encoded_size(input_bytes.len(), config)
        .expect("usize overflow when calculating buffer size");

    let mut b64_output = &mut output[0..encoded_size];

    encode_with_padding(&input_bytes, config, encoded_size, &mut b64_output);

    encoded_size
}
/// Encode arbitrary octets as base64.
/// Writes into the supplied output buffer.
///
/// This is useful if you wish to avoid allocation entirely (e.g. encoding into a stack-resident
/// or statically-allocated buffer).
///
/// # Panics
///
/// If `output` is too small to hold the encoded version of `input`, a panic will result.
///
/// # Example
///
/// ```rust
/// extern crate base64;
///
/// fn main() {
///     let s = b"hello internet!";
///     let mut buf = Vec::new();
///     // make sure we'll have a slice big enough for base64 + padding
///     buf.resize(s.len() * 4 / 3 + 4, 0);
///
///     let bytes_written = base64::encode_config_slice(s,
///                             base64::STANDARD, &mut buf);
///
///     // shorten our vec down to just what was written
///     buf.resize(bytes_written, 0);
///
///     assert_eq!(s, base64::decode(&buf).unwrap().as_slice());
/// }
/// ```
Encode arbitrary octets as base64.
Writes into the supplied output buffer.

This is useful if you wish to avoid allocation entirely .
Encode arbitrary octets as base64 . Writes into the supplied output buffer . This is useful if you wish to avoid allocation entirely .
pub fn encode_config_slice<T: AsRef<[u8]>>(input: T, config: Config, output: &mut [u8]) -> usize {
    let input_bytes = input.as_ref();
    let encoded_size = encoded_size(input_bytes.len(), config)
        .expect("usize overflow when calculating buffer size");
    let mut b64_output = &mut output[0..encoded_size];
    encode_with_padding(&input_bytes, config, encoded_size, &mut b64_output);
    encoded_size
}
pub fn encode_config_slice < T : AsRef < [ u8 ] > > ( input : T , config : Config , output : & mut [ u8 ] ) -> usize { let input_bytes = input . as_ref ( ) ; let encoded_size = encoded_size ( input_bytes . len ( ) , config ) . expect ( " " ) ; let mut b64_output = & mut output [ 0 .. encoded_size ] ; encode_with_padding ( & input_bytes , config , encoded_size , & mut b64_output ) ; encoded_size }
Encode arbitrary octets as base64.
Encode arbitrary octets as base64 .
input
T
config
Config
output
&mut [u8]
input
T
config
Config
output
&mut [u8]
panics
If `output` is too small to hold the encoded version of `input`, a panic will result.
If ` output ` is too small to hold the encoded version of ` input ` a panic will result .
example
```rust
extern crate base64.

fn main() {
let s = b"hello internet!";
let mut buf = Vec::new();
make sure we'll have a slice big enough for base64 + padding
buf.resize(s.len() * 4 / 3 + 4, 0).

let bytes_written = base64::encode_config_slice(s,
base64::STANDARD, &mut buf).

shorten our vec down to just what was written
buf.resize(bytes_written, 0).


` ` ` rust extern crate base64 . fn main () { let s = b " hello internet! " ; let mut buf = Vec :: new () ; make sure we ' ll have a slice big enough for base64 + padding buf . resize ( s . len () * 4 / 3 + 4 0 ) . let bytes_written = base64 :: encode_config_slice ( s base64 :: STANDARD &mut buf ) . shorten our vec down to just what was written buf . resize ( bytes_written 0 ) .