Files
hakorune/src/boxes/http/mod.rs
Moe Charm 44049835d1 🐛 fix: コンパイルエラーを修正
主な修正内容:
- ArrayBox/RegexBox/JSONBoxで`push`メソッドの戻り値を適切に処理
- BufferBoxのインポートパスを修正(buffer::BufferBox)
- StreamBoxでArrayBoxを正しくインポート
- HTTPClientBoxをスタブ実装に変更(reqwest依存を一時的に無効化)

テストプログラムも追加:
- test_array_box_simple.nyash: ArrayBoxの基本テスト
- test_new_boxes.nyash: 全Box実装の統合テスト

NOTE: HTTPサポートは現在OpenSSL/pkg-config依存のため一時的に無効化。
将来的にはrustls等の純Rust実装への移行を検討。

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-10 13:18:21 +09:00

82 lines
2.4 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//! HttpClientBox 🌐 - HTTP通信
// Nyashの箱システムによるHTTP通信を提供します。
// 参考: 既存Boxの設計思想
//
// NOTE: HTTPサポートは現在開発中です。
// reqwestクレートの依存関係のため、一時的に無効化されています。
use crate::box_trait::{NyashBox, StringBox, BoolBox};
use crate::boxes::map_box::MapBox;
use std::any::Any;
use std::sync::{Arc, Mutex};
#[derive(Debug, Clone)]
pub struct HttpClientBox {
id: u64,
}
impl HttpClientBox {
pub fn new() -> Self {
static mut COUNTER: u64 = 0;
let id = unsafe {
COUNTER += 1;
COUNTER
};
HttpClientBox { id }
}
/// HTTP GETリクエストスタブ
pub fn http_get(&self, url: Box<dyn NyashBox>) -> Box<dyn NyashBox> {
Box::new(StringBox::new("HTTP support is currently disabled"))
}
/// HTTP POSTリクエストスタブ
pub fn post(&self, url: Box<dyn NyashBox>, body: Box<dyn NyashBox>) -> Box<dyn NyashBox> {
Box::new(StringBox::new("HTTP support is currently disabled"))
}
/// HTTP PUT リクエスト(スタブ)
pub fn put(&self, url: Box<dyn NyashBox>, body: Box<dyn NyashBox>) -> Box<dyn NyashBox> {
Box::new(StringBox::new("HTTP support is currently disabled"))
}
/// HTTP DELETE リクエスト(スタブ)
pub fn delete(&self, url: Box<dyn NyashBox>) -> Box<dyn NyashBox> {
Box::new(StringBox::new("HTTP support is currently disabled"))
}
/// ヘッダー付きHTTPリクエストスタブ
pub fn request(&self, method: Box<dyn NyashBox>, url: Box<dyn NyashBox>, options: Box<dyn NyashBox>) -> Box<dyn NyashBox> {
Box::new(StringBox::new("HTTP support is currently disabled"))
}
}
impl NyashBox for HttpClientBox {
fn clone_box(&self) -> Box<dyn NyashBox> {
Box::new(self.clone())
}
fn to_string_box(&self) -> StringBox {
StringBox::new(format!("HttpClientBox(id: {})", self.id))
}
fn as_any(&self) -> &dyn Any {
self
}
fn type_name(&self) -> &'static str {
"HttpClientBox"
}
fn box_id(&self) -> u64 {
self.id
}
fn equals(&self, other: &dyn NyashBox) -> BoolBox {
if let Some(other_http) = other.as_any().downcast_ref::<HttpClientBox>() {
BoolBox::new(self.id == other_http.id)
} else {
BoolBox::new(false)
}
}
}