[][src]Function engine_io_parser::string::encoder::encode_base64_packet

pub fn encode_base64_packet(input: &Packet) -> String

Encode a packet with binary data to a UTF-8 string. Note: calling encode_payload with Packets containing binary data also results in base64-encoded output.

Arguments

  • input - A Packet with binary data

Example

use engine_io_parser::packet::{Packet, PacketData, PacketType};
use engine_io_parser::string::encoder::*;

assert_eq!(
    encode_base64_packet(&Packet {
       packet_type: PacketType::Message,
       data: vec![1u8, 2u8, 3u8, 4u8].into(),
    }),
    "4AQIDBA=="
);