Files
hakorune/src/boxes/file/errors.rs
nyash-codex fce7555e46 feat(phase111): FileHandleBox append+metadata実装(修正案統合版)
Task 2: FsApi / Ring0FsFileIo 拡張
- FsApi trait に append_all(path, data) メソッド追加
- StdFsApi で append_all() を std::fs::OpenOptions で実装
- Ring0FsFileIo に mode を保持、write() で truncate/append を切り替え
- Ring0FsFileIo に内部 metadata() ヘルパ追加(FsApi.metadata() 呼び出し)

Task 3: FileHandleBox API 実装
- open(path, mode) で "r"/"w"/"a" 3モードをサポート
- write_all() で read-only mode チェック
- 内部 Rust API:size / exists / is_file / is_dir メソッド実装
  (NyashBox 公開は Phase 112+ に延期)

Task 5: テスト + ドキュメント
- 4つの新テスト PASS:
  - test_filehandlebox_append_mode(write→append→内容確認)
  - test_filehandlebox_metadata_size(size() 取得)
  - test_filehandlebox_metadata_is_file(is_file()/is_dir())
  - test_filehandlebox_write_readonly_error("r"で write 拒否)

統計:
- 9ファイル修正(+316行, -35行)
- 4つの新テスト追加(既存15テスト全PASS)
- cargo build --release: SUCCESS
- 11個のチェックリスト:  ALL PASS

次フェーズ(Phase 112-114)の backlog も指示書で整理済み

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 21:30:47 +09:00

62 lines
1.9 KiB
Rust

//! Phase 110.5: FileBox/FileHandleBox shared error messages
//!
//! This module provides a single source of truth for all error messages
//! used across FileBox and FileHandleBox implementations.
//!
//! # Design Benefits
//!
//! - **SSOT**: All error messages defined in one place
//! - **i18n Ready**: Easy to internationalize later
//! - **Consistency**: Identical errors across FileBox and FileHandleBox
//! - **Maintainability**: Update once, apply everywhere
/// Provider not initialized error (FileBox/FileHandleBox common)
pub fn provider_not_initialized() -> String {
"FileBox provider not initialized".to_string()
}
/// File I/O disabled in no-fs profile (FileHandleBox specific)
pub fn provider_disabled_in_nofs_profile() -> String {
"File I/O disabled in no-fs profile. FileHandleBox is not available.".to_string()
}
/// FileHandleBox already open error
pub fn already_open() -> String {
"FileHandleBox is already open. Call close() first.".to_string()
}
/// FileHandleBox not open error
pub fn not_open() -> String {
"FileHandleBox is not open".to_string()
}
/// Unsupported mode error (with mode name)
pub fn unsupported_mode(mode: &str) -> String {
format!("Unsupported mode: {}. Use 'r', 'w', or 'a'", mode)
}
/// Read not supported by provider
pub fn read_not_supported() -> String {
"Read not supported by FileBox provider".to_string()
}
/// Write not supported by provider
pub fn write_not_supported() -> String {
"Write not supported by FileBox provider".to_string()
}
/// No provider available
pub fn no_provider_available() -> String {
"No provider available".to_string()
}
/// FileHandleBox opened in read mode (cannot write)
pub fn opened_in_read_mode() -> String {
"FileHandleBox opened in read mode".to_string()
}
/// Read-only provider error message
pub fn write_not_supported_readonly() -> String {
"Error: write not supported by provider (read-only)".to_string()
}