copypasta_ext/
combined.rs

1use copypasta::ClipboardProvider;
2
3/// Combined, use different clipboard context for getting & setting.
4///
5/// Useful to combine different clipboard contexts to get the best of both worlds.
6///
7/// This may be constructed using helpers such as
8/// [`X11BinClipboardContext::new_with_x11`][new_with_x11] or
9/// [`X11BinClipboardContext::with_x11`][with_x11].
10///
11/// [new_with_x11]: ../copypasta_ext/x11_bin/struct.X11BinClipboardContext.html#method.new_with_x11
12/// [with_x11]: ../copypasta_ext/x11_bin/struct.X11BinClipboardContext.html#method.with_x11
13pub struct CombinedClipboardContext<G, S>(pub G, pub S)
14where
15    G: ClipboardProvider,
16    S: ClipboardProvider;
17
18// impl<G, S> CombinedClipboardContext<G, S>
19// where
20//     G: ClipboardProvider,
21//     S: ClipboardProvider,
22// {
23//     pub fn new() -> Result<Self, Box<dyn Error>> {
24//         Ok(Self(G::new()?, S::new()?))
25//     }
26// }
27
28impl<G, S> ClipboardProvider for CombinedClipboardContext<G, S>
29where
30    G: ClipboardProvider,
31    S: ClipboardProvider,
32{
33    fn get_contents(&mut self) -> crate::ClipResult<String> {
34        self.0.get_contents()
35    }
36
37    fn set_contents(&mut self, contents: String) -> crate::ClipResult<()> {
38        self.1.set_contents(contents)
39    }
40}