pub struct ImageHandler { /* private fields */ }Expand description
Handles image drag-and-drop events and file operations.
Implementations§
Source§impl ImageHandler
impl ImageHandler
Sourcepub fn new(config: ImageConfig) -> Self
pub fn new(config: ImageConfig) -> Self
Create a new image handler with the given configuration.
Sourcepub fn with_default_config() -> ImageResult<Self>
pub fn with_default_config() -> ImageResult<Self>
Create a new image handler with default configuration.
Sourcepub fn read_image(&self, path: &Path) -> ImageResult<ImageMetadata>
pub fn read_image(&self, path: &Path) -> ImageResult<ImageMetadata>
Read an image file and validate it.
§Arguments
path- Path to the image file
§Returns
Image metadata if successful, error otherwise
§Requirements
- Req 1.2: Read file using ricecoder-files integration
- Req 1.3: Validate format (PNG, JPG, GIF, WebP)
- Req 1.5: Report error with format details
- Security: Sanitize file paths to prevent directory traversal
Sourcepub fn validate_format(&self, format: ImageFormat) -> ImageResult<()>
pub fn validate_format(&self, format: ImageFormat) -> ImageResult<()>
Sourcepub fn handle_dropped_files(
&self,
paths: &[PathBuf],
) -> (Vec<ImageMetadata>, Vec<ImageError>)
pub fn handle_dropped_files( &self, paths: &[PathBuf], ) -> (Vec<ImageMetadata>, Vec<ImageError>)
Sourcepub fn config(&self) -> &ImageConfig
pub fn config(&self) -> &ImageConfig
Get the configuration.
Sourcepub fn extract_paths_from_event(event_data: &str) -> Vec<PathBuf>
pub fn extract_paths_from_event(event_data: &str) -> Vec<PathBuf>
Extract file paths from a drag-and-drop event.
§Arguments
event_data- Raw event data from the terminal (typically file paths)
§Returns
Vector of file paths extracted from the event
§Requirements
- Req 1.1: Create interface for receiving drag-and-drop events from ricecoder-tui
- Req 1.1: Implement file path extraction from events
Sourcepub fn check_file_accessible(path: &Path) -> ImageResult<()>
pub fn check_file_accessible(path: &Path) -> ImageResult<()>
Sourcepub fn process_drag_drop_event(
&self,
event_data: &str,
) -> (Vec<ImageMetadata>, Vec<ImageError>)
pub fn process_drag_drop_event( &self, event_data: &str, ) -> (Vec<ImageMetadata>, Vec<ImageError>)
Process a drag-and-drop event with multiple files.
§Arguments
event_data- Raw event data from the terminal
§Returns
Tuple of (successfully processed images, errors encountered)
§Requirements
- Req 1.1: Handle multiple files in single drag-and-drop
- Req 1.1: Implement file existence and permission checks
Auto Trait Implementations§
impl Freeze for ImageHandler
impl RefUnwindSafe for ImageHandler
impl Send for ImageHandler
impl Sync for ImageHandler
impl Unpin for ImageHandler
impl UnwindSafe for ImageHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more