Skip to main content

Module content

Module content 

Source
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§

BytesContent
Content already held in memory: clipboard drops, web File payloads, tests.
ContentChannel
The producing half of a ContentStream fed by a platform callback.
ContentMetadata
Everything a provider can state about a piece of content without reading it.
FileContent
A file on the local filesystem.
FileFolder
A directory on the local filesystem.
FileSink
A file being written through a temporary sibling, renamed on ContentSink::finish so a partial write never replaces a good file.
ReadyFolder
A folder whose children are already known.

Enums§

ContentEntry
One child of a ContentFolder.
ContentError
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.
ContentFolder
A folder granted by a provider.
ContentReader
A pull reader over one piece of content.
ContentResolver
Turns a provider URI into readable content.
ContentSink
A writable destination for streamed content.
ContentStream
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::next incrementally.
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 uri through the platform resolver, falling back to the local filesystem for file:// 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 bytes into sink and commits it.

Type Aliases§

ContentFolderRef
Shared handle to a ContentFolder.
ContentFuture
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.
ContentHandle
Shared handle to a Content.
ContentReaderRef
Shared handle to a ContentReader.
ContentResolverRef
Shared handle to a ContentResolver.
ContentSinkRef
Shared handle to a ContentSink.
ContentStreamRef
Shared handle to a ContentStream.