mirror of
https://github.com/ForeverPyrite/r2client.git
synced 2025-12-10 01:38:07 +00:00
Added Result type and minor consistency changes
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
name = "aws_sigv4"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
authors = ["foreverpyrite <r2client@foreverpyrite.com"]
|
||||
description = "Minimal-dependancy library to sign requests via AWS's SigV4."
|
||||
|
||||
[lib]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name = "r2client"
|
||||
version = "0.2.0"
|
||||
edition = "2024"
|
||||
authors = ["ForeverPyrite <r2@foreverpyrite.com"]
|
||||
authors = ["foreverpyrite <r2client@foreverpyrite.com"]
|
||||
|
||||
[lib]
|
||||
|
||||
|
||||
@@ -7,6 +7,19 @@ use reqwest::header::HeaderMap;
|
||||
use std::collections::HashMap;
|
||||
use std::str::FromStr;
|
||||
|
||||
|
||||
// I wonder if something like this would be better for error handling instead of a hardcoded
|
||||
// string?
|
||||
// Of course it'll only be for this codebase, but it would make the code more maintainable, right?
|
||||
// #[derive(Debug)]
|
||||
// enum R2Operation {
|
||||
// Delete,
|
||||
// Download,
|
||||
// Upload,
|
||||
// ListFiles,
|
||||
// ListAll
|
||||
// }
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct R2Client {
|
||||
sigv4: SigV4Credentials,
|
||||
@@ -66,7 +79,7 @@ impl R2Client {
|
||||
local_file_path: &str,
|
||||
r2_file_key: &str,
|
||||
content_type: Option<&str>,
|
||||
) -> Result<(), R2Error> {
|
||||
) -> crate::Result {
|
||||
// Payload (file data)
|
||||
let payload = std::fs::read(local_file_path)?;
|
||||
trace!(
|
||||
|
||||
@@ -13,3 +13,5 @@ pub enum R2Error {
|
||||
#[error("Request failed during operation {0}: {1}\n{2}")]
|
||||
FailedRequest(String, http::StatusCode, String),
|
||||
}
|
||||
|
||||
pub type Result = std::result::Result<(), R2Error>;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
mod error;
|
||||
mod mimetypes;
|
||||
pub use error::R2Error;
|
||||
// Should r2client::Result be r2client::R2Result just in case someone does a glob import or
|
||||
// something? Or should that be left to the user of the library to use the "as" keyword?
|
||||
pub use error::{R2Error, Result};
|
||||
|
||||
mod _async;
|
||||
#[cfg(feature = "async")]
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
- [ ] A way to view the file contents (UTF-8 valid) would be cool
|
||||
- [ ] Add functions that will list files with their metadata (perhaps a simple R2File type?)
|
||||
- [ ] Clear out all all print statements and consider logging (this is a library, after all)
|
||||
- [ ] How should buckets act in a multi-threaded environment if they are stored in an Arc or something?
|
||||
|
||||
## Dev (since we're so back):
|
||||
- [X] Update the sync library
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
name = "r2python"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
authors = ["foreverpyrite <r2client@foreverpyrite.com"]
|
||||
|
||||
[dependencies]
|
||||
pyo3 = "0.26.0"
|
||||
|
||||
Reference in New Issue
Block a user