use crate::util::text::{encode_text, TextEncoding};
use std::hash::{Hash, Hasher};
#[derive(Clone, Debug, Eq)]
pub struct EncodedTextFrame {
pub encoding: TextEncoding,
pub description: String,
pub content: String,
}
impl PartialEq for EncodedTextFrame {
fn eq(&self, other: &Self) -> bool {
self.description == other.description
}
}
impl Hash for EncodedTextFrame {
fn hash<H: Hasher>(&self, state: &mut H) {
self.description.hash(state);
}
}
impl EncodedTextFrame {
pub fn as_bytes(&self) -> Vec<u8> {
let mut bytes = vec![self.encoding as u8];
bytes.extend(encode_text(&self.description, self.encoding, true).iter());
bytes.extend(encode_text(&self.content, self.encoding, false));
bytes
}
}