mirror of https://github.com/zkat/cacache-rs.git
feat(read): added content read and read_to_string
This commit is contained in:
parent
e452fdcd16
commit
70cf52e136
|
|
@ -1,12 +1,21 @@
|
|||
use crate::content::path::content_path;
|
||||
use ssri::Integrity;
|
||||
use std::path::Path;
|
||||
use std::fs::File;
|
||||
use std::fs::{self, File};
|
||||
use std::io;
|
||||
|
||||
pub fn open(cache: &Path, sri: &Integrity) -> std::io::Result<File> {
|
||||
pub fn open(cache: &Path, sri: &Integrity) -> io::Result<File> {
|
||||
File::open(content_path(&cache, &sri))
|
||||
}
|
||||
|
||||
pub fn copy(cache: &Path, sri: &Integrity, to: &Path) -> std::io::Result<u64> {
|
||||
std::fs::copy(content_path(&cache, &sri), to)
|
||||
pub fn read(cache: &Path, sri: &Integrity) -> io::Result<Vec<u8>> {
|
||||
fs::read(content_path(&cache, &sri))
|
||||
}
|
||||
|
||||
pub fn read_to_string(cache: &Path, sri: &Integrity) -> io::Result<String> {
|
||||
fs::read_to_string(content_path(&cache, &sri))
|
||||
}
|
||||
|
||||
pub fn copy(cache: &Path, sri: &Integrity, to: &Path) -> io::Result<u64> {
|
||||
fs::copy(content_path(&cache, &sri), to)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue