Expand description
Streaming content: the single shape every byte source hands the application.
File picking, incoming shares, document intents, dropped files and media
sources all resolve to a ContentHandle. A handle carries
ContentMetadata and opens a ContentReader that yields chunks, so a
multi-gigabyte media file and a two-byte clipboard drop travel the same API
and neither forces the application to buffer a whole payload.
Folders resolve to a ContentFolderRef. Their trees are consumed through
folder_files, which returns a ContentStream: an asynchronous stream
whose next future wakes its collector when the provider discovers another
file. Nothing here polls.
Structs§
- Bytes
Content - Content already held in memory: clipboard drops, web
Filepayloads, tests. - Content
Channel - The producing half of a
ContentStreamfed by a platform callback. - Content
Metadata - Everything a provider can state about a piece of content without reading it.
- File
Content - A file on the local filesystem.
- File
Folder - A directory on the local filesystem.
- File
Sink - A file being written through a temporary sibling, renamed on
ContentSink::finishso a partial write never replaces a good file. - Ready
Folder - A folder whose children are already known.
Enums§
- Content
Entry - One child of a
ContentFolder. - Content
Error - Errors produced while reading or writing content.
Constants§
- DEFAULT_
CHUNK_ LEN - Chunk size the framework’s own readers hand back per
ContentReader::read_chunk.
Traits§
- Content
- One readable piece of content from any source.
- Content
Folder - A folder granted by a provider.
- Content
Reader - A pull reader over one piece of content.
- Content
Resolver - Turns a provider URI into readable content.
- Content
Sink - A writable destination for streamed content.
- Content
Stream - An asynchronous stream of content.
Functions§
- clear_
platform_ content_ resolver - Removes any installed platform content resolver.
- collect_
stream - Collects an entire stream. Convenient for tests and small trees; production
collectors consume
ContentStream::nextincrementally. - drain_
reader - Reads a reader to its end.
- file_
content - A shared handle to the file at
path. - file_
folder - A shared handle to the directory at
path. - folder_
files - Streams every file in
folder’s tree, using the provider’s native stream when it has one and a depth-first walk otherwise. - percent_
decode - Decodes the percent-escapes in a platform content URI, refusing input it cannot decode exactly.
- percent_
decode_ lossy - Decodes the percent-escapes in a platform content URI for display.
- resolve_
content - Resolves
urithrough the platform resolver, falling back to the local filesystem forfile://URIs and plain paths. - set_
platform_ content_ resolver - Installs the platform content resolver (Android’s
ContentResolver, the iOS document store, the browser’s blob registry). - write_
all - Writes every byte of
bytesintosinkand commits it.
Type Aliases§
- Content
Folder Ref - Shared handle to a
ContentFolder. - Content
Future - A future produced by a content operation. It borrows the content it reads from, so no implementation has to clone a handle into every call.
- Content
Handle - Shared handle to a
Content. - Content
Reader Ref - Shared handle to a
ContentReader. - Content
Resolver Ref - Shared handle to a
ContentResolver. - Content
Sink Ref - Shared handle to a
ContentSink. - Content
Stream Ref - Shared handle to a
ContentStream.