aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/util/http_downloader.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-22 23:14:27 +0900
committernsfisis <nsfisis@gmail.com>2026-05-23 15:48:00 +0900
commit5adc4e467f01865ba2d4f519334ee1b0496b8ebf (patch)
treef6970f181793c0f8b9b67b2af54c09ae13a25c4b /crates/shirabe/src/util/http_downloader.rs
parent2a1696906344cb4da768a940bf8b1f89bbc82b47 (diff)
downloadphp-shirabe-5adc4e467f01865ba2d4f519334ee1b0496b8ebf.tar.gz
php-shirabe-5adc4e467f01865ba2d4f519334ee1b0496b8ebf.tar.zst
php-shirabe-5adc4e467f01865ba2d4f519334ee1b0496b8ebf.zip
refactor(promise): change functions returning PromiseInterface to async fn
Diffstat (limited to 'crates/shirabe/src/util/http_downloader.rs')
-rw-r--r--crates/shirabe/src/util/http_downloader.rs16
1 files changed, 5 insertions, 11 deletions
diff --git a/crates/shirabe/src/util/http_downloader.rs b/crates/shirabe/src/util/http_downloader.rs
index 3072df2..6f769ce 100644
--- a/crates/shirabe/src/util/http_downloader.rs
+++ b/crates/shirabe/src/util/http_downloader.rs
@@ -5,8 +5,6 @@ use indexmap::IndexMap;
use crate::util::Silencer;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
-use shirabe_external_packages::react::promise::Promise;
-use shirabe_external_packages::react::promise::PromiseInterface;
use shirabe_php_shim::{
InvalidArgumentException, LogicException, PhpMixed, array_replace_recursive, chr,
extension_loaded, file_get_contents, function_exists, implode, is_numeric, max, min,
@@ -203,11 +201,11 @@ impl HttpDownloader {
}
/// Create an async download operation
- pub fn add(
+ pub async fn add(
&mut self,
url: &str,
options: IndexMap<String, PhpMixed>,
- ) -> Result<Box<dyn PromiseInterface>> {
+ ) -> Result<Response> {
if "" == url {
return Err(InvalidArgumentException {
message: "$url must not be an empty string".to_string(),
@@ -255,12 +253,12 @@ impl HttpDownloader {
}
/// Create an async copy operation
- pub fn add_copy(
+ pub async fn add_copy(
&mut self,
url: &str,
to: &str,
options: IndexMap<String, PhpMixed>,
- ) -> Result<Box<dyn PromiseInterface>> {
+ ) -> Result<Response> {
if "" == url {
return Err(InvalidArgumentException {
message: "$url must not be an empty string".to_string(),
@@ -292,11 +290,7 @@ impl HttpDownloader {
/// @phpstan-param Request $request
/// @return array{Job, PromiseInterface}
- fn add_job(
- &mut self,
- mut request: Request,
- sync: bool,
- ) -> Result<(JobHandle, Box<dyn PromiseInterface>)> {
+ async fn add_job(&mut self, mut request: Request, sync: bool) -> Result<(JobHandle, Response)> {
request.options = array_replace_recursive(self.options.clone(), request.options);
let id = self.id_gen;