//! 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) -> Box { Box::new(StringBox::new("HTTP support is currently disabled")) } /// HTTP POSTリクエスト(スタブ) pub fn post(&self, url: Box, body: Box) -> Box { Box::new(StringBox::new("HTTP support is currently disabled")) } /// HTTP PUT リクエスト(スタブ) pub fn put(&self, url: Box, body: Box) -> Box { Box::new(StringBox::new("HTTP support is currently disabled")) } /// HTTP DELETE リクエスト(スタブ) pub fn delete(&self, url: Box) -> Box { Box::new(StringBox::new("HTTP support is currently disabled")) } /// ヘッダー付きHTTPリクエスト(スタブ) pub fn request(&self, method: Box, url: Box, options: Box) -> Box { Box::new(StringBox::new("HTTP support is currently disabled")) } } impl NyashBox for HttpClientBox { fn clone_box(&self) -> Box { 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::() { BoolBox::new(self.id == other_http.id) } else { BoolBox::new(false) } } }