refactor: 大規模リファクタリングPhase完了 - SRP原則による品質向上
🎯 実行内容: • box_operators.rs: 639行 → 26%構造改善 (Phase 1-2完了) - マクロ抽出: macros.rs (演算子実装統一) - ヘルパー分離: helpers.rs (共通ユーティリティ) - 静的実装分離: static_ops.rs (静的演算子) • arithmetic boxes: 完全モジュール分割 - 6種類の演算Box (add/subtract/multiply/divide/modulo/compare) • plugin_loader_v2: 7モジュール完全分割 - config/library/metadata/singletons/specs/util分離 • nyash-net-plugin: 緊急修正完了 (27エラー→0) - import解決問題・マクロスコープ問題・関数構造問題修正 • nyash-filebox-plugin: モジュール統合・冗長削除 📊 成果: • SRP原則適用による保守性向上 • 大規模ファイル分割による可読性改善 • プラグインビルドエラー完全解決 • モジュール境界明確化・再利用性向上 🔧 検証済み: 全スモークテスト正常動作確認 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -127,12 +127,7 @@ pub fn tlv_parse_handle_at(data: &[u8], pos: &mut usize) -> Result<(u32, u32), (
|
||||
if len != 8 || data.len() < *pos + 8 {
|
||||
return Err(());
|
||||
}
|
||||
let type_id = u32::from_le_bytes([
|
||||
data[*pos],
|
||||
data[*pos + 1],
|
||||
data[*pos + 2],
|
||||
data[*pos + 3],
|
||||
]);
|
||||
let type_id = u32::from_le_bytes([data[*pos], data[*pos + 1], data[*pos + 2], data[*pos + 3]]);
|
||||
let instance_id = u32::from_le_bytes([
|
||||
data[*pos + 4],
|
||||
data[*pos + 5],
|
||||
@ -148,7 +143,7 @@ pub fn tlv_parse_bytes_at(data: &[u8], pos: &mut usize) -> Result<Vec<u8>, ()> {
|
||||
return Err(());
|
||||
}
|
||||
let tag = data[*pos];
|
||||
if tag != TLV_TAG_BYTES {
|
||||
if tag != TLV_TAG_BYTES && tag != TLV_TAG_STRING {
|
||||
return Err(());
|
||||
}
|
||||
let len = u16::from_le_bytes([data[*pos + 2], data[*pos + 3]]) as usize;
|
||||
@ -161,6 +156,47 @@ pub fn tlv_parse_bytes_at(data: &[u8], pos: &mut usize) -> Result<Vec<u8>, ()> {
|
||||
Ok(bytes)
|
||||
}
|
||||
|
||||
pub fn tlv_parse_string(data: &[u8]) -> Result<String, ()> {
|
||||
let (_, argc, mut pos) = tlv_parse_header(data)?;
|
||||
if argc < 1 {
|
||||
return Err(());
|
||||
}
|
||||
tlv_parse_string_at(data, &mut pos)
|
||||
}
|
||||
|
||||
pub fn tlv_parse_bytes(data: &[u8]) -> Result<Vec<u8>, ()> {
|
||||
let (_, argc, mut pos) = tlv_parse_header(data)?;
|
||||
if argc < 1 {
|
||||
return Err(());
|
||||
}
|
||||
tlv_parse_bytes_at(data, &mut pos)
|
||||
}
|
||||
|
||||
pub fn tlv_parse_optional_string_and_bytes(data: &[u8]) -> Result<(Option<String>, Vec<u8>), ()> {
|
||||
let (_, argc, mut pos) = tlv_parse_header(data)?;
|
||||
match argc {
|
||||
0 => Err(()),
|
||||
1 => {
|
||||
let bytes = tlv_parse_bytes_at(data, &mut pos)?;
|
||||
Ok((None, bytes))
|
||||
}
|
||||
_ => {
|
||||
let s = tlv_parse_string_at(data, &mut pos)?;
|
||||
let bytes = tlv_parse_bytes_at(data, &mut pos)?;
|
||||
Ok((Some(s), bytes))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tlv_parse_handle(data: &[u8]) -> Result<(u32, u32), ()> {
|
||||
let (_, argc, mut pos) = tlv_parse_header(data)?;
|
||||
if argc < 1 {
|
||||
return Err(());
|
||||
}
|
||||
let (type_id, instance_id) = tlv_parse_handle_at(data, &mut pos)?;
|
||||
Ok((type_id, instance_id))
|
||||
}
|
||||
|
||||
pub fn tlv_parse_one_string(data: &[u8]) -> Result<String, ()> {
|
||||
let (_, argc, mut pos) = tlv_parse_header(data)?;
|
||||
if argc < 1 {
|
||||
@ -177,4 +213,4 @@ pub fn tlv_parse_string_and_bytes(data: &[u8]) -> Result<(String, Vec<u8>), ()>
|
||||
let s = tlv_parse_string_at(data, &mut pos)?;
|
||||
let b = tlv_parse_bytes_at(data, &mut pos)?;
|
||||
Ok((s, b))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user