Document stream methods

This commit is contained in:
asonix 2020-06-19 12:43:21 -05:00
parent e6407c4cb3
commit 11ff7ca55a
4 changed files with 634 additions and 376 deletions

View file

@ -3,7 +3,7 @@ name = "actix-fs"
description = "Asynchronous filesystem operations for actix-based systems"
version = "0.1.0"
authors = ["asonix <asonix@asonix.dog>"]
license-file = "LICENSE"
license = "AGPL-3.0"
readme = "README.md"
repository = "https://git.asonix.dog/asonix/actix-fs"
keywords = ["actix", "fs", "filesystem"]

968
LICENSE

File diff suppressed because it is too large Load diff

View file

@ -19,19 +19,14 @@ async fn main() -> Result<(), anyhow::Error> {
```
### Contributing
Unless otherwise stated, all contributions to this project will be licensed under the CSL with
the exceptions listed in the License section of this file.
Feel free to open issues for anything you find an issue with. Please note that any contributed code will be licensed under the AGPLv3.
### License
This work is licensed under the Cooperative Software License. This is not a Free Software
License, but may be considered a "source-available License." For most hobbyists, self-employed
developers, worker-owned companies, and cooperatives, this software can be used in most
projects so long as this software is distributed under the terms of the CSL. For more
information, see the provided LICENSE file. If none exists, the license can be found online
[here](https://lynnesbian.space/csl/). If you are a free software project and wish to use this
software under the terms of the GNU Affero General Public License, please contact me at
[asonix@asonix.dog](mailto:asonix@asonix.dog) and we can sort that out. If you wish to use this
project under any other license, especially in proprietary software, the answer is likely no.
Actix FS is currently licensed under the AGPL to the Lemmy project, found
at [github.com/LemmyNet/lemmy](https://github.com/LemmyNet/lemmy)
Copyright © 2020 Riley Trautman
pict-rs is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
pict-rs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. This file is part of pict-rs.
You should have received a copy of the GNU General Public License along with pict-rs. If not, see [http://www.gnu.org/licenses/](http://www.gnu.org/licenses/).

View file

@ -480,11 +480,30 @@ impl FileStream {
})
}
/// Change the size of chunks read by the stream
///
/// This can be used to only read certain bytes from a given file
///
/// ```no_run
/// #[actix_rt::main]
/// async fn main() -> actix_fs::Result<()> {
/// let f = actix_fs::file::open("foo.txt").await?;
/// let (f, _) = actix_fs::file::seek(std::io::SeekFrom::Start(16)).await?;
/// let mut stream = actix_fs::file::read_to_stream(f).await?.chunk_size(16);
///
/// if let Some(res) = stream.next().await {
/// let sixteen_bytes = res?;
/// // ...
/// }
/// Ok(())
/// }
/// ```
pub fn chunk_size(mut self, chunk_size: u64) -> Self {
self.chunk_size = chunk_size;
self
}
/// Get the size of the file being streamed
pub fn size(&self) -> u64 {
self.size
}