mirror of https://github.com/zkat/cacache-rs.git
fix(api): use &str keys
This commit is contained in:
parent
b54a3a4f82
commit
cf0fbe233f
|
|
@ -7,7 +7,7 @@ use crate::content::read;
|
|||
use crate::errors::Error;
|
||||
use crate::index::{self, Entry};
|
||||
|
||||
pub fn read(cache: &Path, key: String) -> Result<Vec<u8>, Error> {
|
||||
pub fn read(cache: &Path, key: &str) -> Result<Vec<u8>, Error> {
|
||||
if let Some(entry) = index::find(&cache, &key)? {
|
||||
read_hash(cache, &entry.integrity)
|
||||
} else {
|
||||
|
|
@ -19,7 +19,7 @@ pub fn read_hash(cache: &Path, sri: &Integrity) -> Result<Vec<u8>, Error> {
|
|||
Ok(read::read(cache, sri)?)
|
||||
}
|
||||
|
||||
pub fn copy(cache: &Path, key: String, to: &Path) -> Result<u64, Error> {
|
||||
pub fn copy(cache: &Path, key: &str, to: &Path) -> Result<u64, Error> {
|
||||
if let Some(entry) = index::find(&cache, &key)? {
|
||||
copy_hash(cache, &entry.integrity, to)
|
||||
} else {
|
||||
|
|
@ -31,7 +31,7 @@ pub fn copy_hash(cache: &Path, sri: &Integrity, to: &Path) -> Result<u64, Error>
|
|||
Ok(read::copy(cache, sri, to)?)
|
||||
}
|
||||
|
||||
pub fn info(cache: &Path, key: String) -> Result<Option<Entry>, Error> {
|
||||
pub fn info(cache: &Path, key: &str) -> Result<Option<Entry>, Error> {
|
||||
index::find(cache, &key)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use crate::content::write;
|
|||
use crate::index;
|
||||
use crate::errors::Error;
|
||||
|
||||
pub fn data(cache: &Path, key: String, data: Vec<u8>) -> Result<Integrity, Error> {
|
||||
pub fn data(cache: &Path, key: &str, data: Vec<u8>) -> Result<Integrity, Error> {
|
||||
let sri = write::write(&cache, &data)?;
|
||||
Writer::new(cache, &key).integrity(sri).commit(data)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue