mirbuilder: integrate Normalizer (toggle), add tag-quiet mode, share f64 canonicalization; expand canaries; doc updates for quick timeout + dev toggles; Phase 21.5 optimization readiness
This commit is contained in:
@ -1,50 +1,4 @@
|
||||
//! Core read‑only File I/O provider (ring‑1).
|
||||
//! Provides basic read-only file operations using std::fs::File.
|
||||
|
||||
use super::provider::{FileCaps, FileError, FileIo, FileResult, normalize_newlines};
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::sync::RwLock;
|
||||
|
||||
pub struct CoreRoFileIo {
|
||||
handle: RwLock<Option<File>>,
|
||||
}
|
||||
|
||||
impl CoreRoFileIo {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
handle: RwLock::new(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FileIo for CoreRoFileIo {
|
||||
fn caps(&self) -> FileCaps {
|
||||
FileCaps::read_only()
|
||||
}
|
||||
|
||||
fn open(&self, path: &str) -> FileResult<()> {
|
||||
let file = File::open(path)
|
||||
.map_err(|e| FileError::Io(format!("Failed to open {}: {}", path, e)))?;
|
||||
*self.handle.write().unwrap() = Some(file);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn read(&self) -> FileResult<String> {
|
||||
let mut handle = self.handle.write().unwrap();
|
||||
if let Some(ref mut file) = *handle {
|
||||
let mut content = String::new();
|
||||
file.read_to_string(&mut content)
|
||||
.map_err(|e| FileError::Io(format!("Read failed: {}", e)))?;
|
||||
Ok(normalize_newlines(&content))
|
||||
} else {
|
||||
Err(FileError::Io("No file opened".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
fn close(&self) -> FileResult<()> {
|
||||
*self.handle.write().unwrap() = None;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
//! Core read‑only File I/O provider (ring‑1) — moved under `src/providers/ring1/file/core_ro.rs`.
|
||||
//! This module re-exports the ring1 implementation to keep legacy paths working.
|
||||
|
||||
pub use crate::providers::ring1::file::core_ro::CoreRoFileIo;
|
||||
|
||||
Reference in New Issue
Block a user