1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//! Virtual file transfer through Windows drag-and-drop and
//! the clipboard.
//!
//! This crate allows applications to offer data as files
//! without first writing the contents to temporary files.
//!
//! File contents are provided on demand using [`FileSource`]
//! and [`SourceReader`]. On Windows, these are exposed to
//! receiving applications through OLE `IDataObject` and
//! `IStream` interfaces.
//!
//! # Quick start
//!
//! ```no_run
//! use std::io::Cursor;
//! use virtual_file_transfer::{
//! begin_drag, FactorySource, SourceReader, VirtualFile,
//! };
//!
//! fn start_drag() -> virtual_file_transfer::Result<()> {
//! let source = FactorySource::new(|| {
//! Ok(SourceReader::seekable(
//! Cursor::new(b"hello\n".to_vec())
//! ))
//! });
//!
//! let file = VirtualFile::new(
//! "hello.txt",
//! Box::new(source),
//! )?;
//!
//! let _handle = begin_drag(vec![file])?;
//! Ok(())
//! }
//! ```
//!
//! Call [`begin_drag`] from an appropriate Windows UI event
//! handler. The application must provide a message loop.
//!
//! # Data sources
//!
//! A [`FileSource`] produces a fresh [`SourceReader`] for
//! each request. Sources may read from memory, archives,
//! generated content, or other application-defined storage.
//!
//! Use [`SourceReader::streaming`] for sequential data and
//! [`SourceReader::seekable`] when seeking is available.
//!
//! The optional `spool` feature provides
//! [`SourceReader::spooled`] for explicitly materializing
//! non-seekable data into temporary storage.
//!
//! # Transfer operations
//!
//! - [`begin_drag`] starts an OLE drag-and-drop operation.
//! - [`copy_to_clipboard`] exposes virtual files through
//! the system clipboard.
//! - [`TransferHandle`] provides cancellation and status
//! information.
//!
//! A successful drop does not necessarily mean that an
//! asynchronous receiver has finished reading the data.
//! See [`TransferStatus`] for completion semantics.
//!
//! # Platform support
//!
//! Currently Windows only.
/// Windows-specific APIs, including the lower-level OLE data-object interface.
pub use CancellationToken;
pub use ;
pub use FactorySource;
pub use FileSource;
pub use SourceReader;
pub use ;
pub use VirtualFile;
/// Starts a Windows OLE drag-and-drop operation for the supplied virtual files.
///
/// This calls `DoDragDrop` on the current thread and returns when the drag
/// operation ends. The receiver may continue fetching file contents
/// asynchronously after this function returns.
///
/// Call this from a suitable Windows UI thread with a message loop. The
/// function initializes OLE for the duration of the drag operation.
///
/// The request must contain at least one file and must not contain duplicate
/// or conflicting paths. A `Vec<VirtualFile>` can be passed directly.
///
/// # Errors
///
/// Returns [`Error::InvalidInput`] for invalid transfers or
/// [`Error::Platform`] if OLE initialization or drag-and-drop fails.
/// Keeps a virtual-file clipboard transfer available.
///
/// The session owns the resources needed to serve file
/// contents when another application pastes them.
///
/// Keep this value alive while clipboard data may still
/// be requested.
///
/// Dropping the session clears its clipboard contents
/// if they are still the current clipboard contents.
/// It does not clear data installed by another application
/// or a newer clipboard session.
/// Publishes virtual files through the Windows clipboard.
///
/// The returned [`ClipboardSession`] must remain alive while the data is
/// available for pasting. File contents are provided lazily when the receiver
/// requests them. A `Vec<VirtualFile>` can be passed directly.
///
/// # Errors
///
/// Returns [`Error::InvalidInput`] for an invalid transfer or
/// [`Error::Platform`] if OLE initialization or clipboard registration fails.