use crate::binary;
use crate::codepoint;
use crate::crypto::KeyRing;
use crate::engine::Emoji;
use crate::error::Result;
pub struct EmojiExporter;
impl EmojiExporter {
pub fn to_binary(emoji: &Emoji) -> Result<Vec<u8>> {
binary::write_emoji(emoji, None)
}
pub fn to_binary_encrypted(emoji: &Emoji, keyring: &KeyRing) -> Result<Vec<u8>> {
binary::write_emoji(emoji, Some(keyring))
}
pub fn from_binary(bytes: &[u8]) -> Result<Emoji> {
Ok(Emoji::from_blocks(binary::read_blocks(bytes, None)?))
}
pub fn from_binary_decrypted(bytes: &[u8], keyring: &KeyRing) -> Result<Emoji> {
Ok(Emoji::from_blocks(binary::read_blocks(
bytes,
Some(keyring),
)?))
}
pub fn to_unicode(emoji: &Emoji) -> Result<String> {
codepoint::encode_blocks(&emoji.blocks)
}
pub fn from_unicode(s: &str) -> Result<Emoji> {
Ok(Emoji::from_blocks(codepoint::decode_blocks(s)?))
}
}