<commit_before>extern crate libc;

#[cfg(target_os = "macos")]
extern crate cocoa;

#[cfg(target_os = "windows")]
extern crate winapi;

#[cfg(target_os = "windows")]
extern crate user32;

#[cfg(target_os = "windows")]
extern crate kernel32;

#[cfg(target_os = "linux")]
extern crate x11_dl;

#[cfg(target_os = "macos")]
mod mac_clipboard;

#[cfg(target_os = "windows")]
mod windows_clipboard;

#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd"))]
mod unix_clipboard;

#[cfg(target_os = "macos")]
pub type NativeClipboard = mac_clipboard::CocoaClipboard;

#[cfg(target_os = "windows")]
pub type NativeClipboard = windows_clipboard::WindowsClipboard;

#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd"))]
pub type NativeClipboard = unix_clipboard::UnixClipboard;

pub enum ClipboardCopy<'a> {
    Text(&'a str),
    Other(*mut libc::c_void)
}

pub trait Clipboard {
    fn copy(&mut self, item: ClipboardCopy);
    fn get_paste_text(&self) -> &str;
}

#[cfg(all(test, any(target_os = "macos", target_os = "windows", target_os = "linux", target_os = "dragonfly",
                    target_os = "freebsd", target_os = "openbsd")))]
mod tests {
    use super::NativeClipboard;
    use ::Clipboard;
    #[test]
    fn test_native_clipboard() {
        const TEST_TEXT: &'static str = "BoomShakalaka";
        let mut clipboard = NativeClipboard::default();

        // Save the current clipboard text
        let current_clipboard_text = clipboard.get_paste_text().to_string();

        clipboard.copy(TEST_TEXT);
        assert_eq!(clipboard.get_paste_text(), TEST_TEXT);

        // And restore the clipboard to its previous state after the test
        clipboard.copy(&current_clipboard_text);
    }
}
<commit_msg>Add Image trait, and fix tests<commit_after>extern crate libc;

#[cfg(target_os = "macos")]
extern crate cocoa;

#[cfg(target_os = "windows")]
extern crate winapi;

#[cfg(target_os = "windows")]
extern crate user32;

#[cfg(target_os = "windows")]
extern crate kernel32;

#[cfg(target_os = "linux")]
extern crate x11_dl;

#[cfg(target_os = "macos")]
mod mac_clipboard;

#[cfg(target_os = "windows")]
mod windows_clipboard;

#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd"))]
mod unix_clipboard;

#[cfg(target_os = "macos")]
pub type NativeClipboard = mac_clipboard::CocoaClipboard;

#[cfg(target_os = "windows")]
pub type NativeClipboard = windows_clipboard::WindowsClipboard;

#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd"))]
pub type NativeClipboard = unix_clipboard::UnixClipboard;

pub trait Image {
    type Error;
    fn get_bytes(&self) -> &[u8];
    fn from_bytes(bytes: &[u8]) -> Result<Self, Self::Error> where Self: Sized;
}

pub enum ClipboardCopy<'a> {
    Text(&'a str),
    Other(*mut libc::c_void)
}

pub trait Clipboard {
    fn copy(&mut self, item: ClipboardCopy);
    fn get_paste_text(&self) -> &str;
}

#[cfg(all(test, any(target_os = "macos", target_os = "windows", target_os = "linux", target_os = "dragonfly",
                    target_os = "freebsd", target_os = "openbsd")))]
mod tests {
    use ::{Clipboard, ClipboardCopy, NativeClipboard};
    #[test]
    fn test_native_clipboard() {
        const TEST_TEXT: &'static str = "BoomShakalaka";
        let mut clipboard = NativeClipboard::default();

        // Save the current clipboard text
        let current_clipboard_text = clipboard.get_paste_text().to_string();

        clipboard.copy(ClipboardCopy::Text(TEST_TEXT));
        assert_eq!(clipboard.get_paste_text(), TEST_TEXT);

        // And restore the clipboard to its previous state after the test
        clipboard.copy(ClipboardCopy::Text(&current_clipboard_text));
    }
}

{'fraction_non_alphanumeric': 0.14505208333333333, 'fraction_numerical': 0.0036458333333333334, 'mean_word_length': 4.526618705035971, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6106295', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1320, 'n_words': 305}