fix(api): use &str keys

This commit is contained in:
Kat Marchán 2019-06-05 14:46:29 +02:00
parent b54a3a4f82
commit cf0fbe233f
No known key found for this signature in database
GPG Key ID: AEB529C08A3C7E9E
2 changed files with 4 additions and 4 deletions

View File

@ -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)
}

View File

@ -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)
}