feat: add core types and update documentation#7
feat: add core types and update documentation#7polw1 wants to merge 3 commits intosilvermine:masterfrom
Conversation
e4e0142 to
62efb18
Compare
|
|
||
| /// Trait for reading media streams from various sources | ||
| #[async_trait] | ||
| pub trait StreamReader: Send + Sync { |
There was a problem hiding this comment.
read and seek should probably be modified to not take &mut self as this complicates ownership.
We may be able to use interior mutability Arc<Mutex<>> to hide the mutable state from the public API.
There was a problem hiding this comment.
I wonder if pushing mutability inside the reader could hurt performance.
For example:
reader.seek(SeekFrom::Start(100)).await?;
reader.read(&mut buf).await?; // lock during async I/OTo avoid a race between seek and read, we’d need to hold the same lock across both operations—which means holding a lock while awaiting I/O.
Considering how we possibly will use the reader, i think it makes sense to use a read_at/size approach and avoid all these problems. What do you think?
There was a problem hiding this comment.
Good point, @polw1. Agree with your suggestion to update the StreamReader trait with a read_at function to eliminate the need for interior mutability. This not only resolves the mutability issue but also enables parallel I/O reads without locks.
It also aligns with patterns used in other crates to support stateless reads with parallel access.
velocitysystems
left a comment
There was a problem hiding this comment.
Handing over to @yokuze for review.
Added Silvermine’s Rust standards and supporting configuration files: * rust-toolchain.toml for version pinning * rustfmt.toml with formatting rules * .cargo/config.toml with lint/fix aliases * Updated README with linting instructions These additions ensure consistency across Rust projects and align with organization-wide practices.
feat: update StreamReader trait to use read_at approach
This PR adds documentation for the
media-parsercrate, including examples of how to use the public API.It also adds the Rust code definitions for the core types and their structs.
Key features covered in the documentation: