Details of the implementation of menyoki.
mod.rs is used for the hierarchy of modules. Every directory in src/
is a module and its general methods/types are contained in a mod.rs
file.
settings.rs
file is commonly used for handling configuration based operations such as conditionally parsing command line arguments to set an option/flag for a particular module. It constructs a struct named XyzSettings
where Xyz
is generally the name of the module.
- main.rs -> starts the application (
App::new(...).start()
) - app.rs ->
App
(contains the application methods such asrecord
,capture
andedit_image
) - settings.rs ->
AppSettings
- analyze
- mod.rs ->
ImageAnalyzer
- settings.rs ->
AnalyzeSettings
- mod.rs ->
- anim
- decoder.rs ->
AnimDecoder
- mod.rs -> module declarations
- settings.rs ->
AnimSettings
- decoder.rs ->
- apng
- mod.rs ->
ApngEncoder
- mod.rs ->
- args
- matches.rs ->
ArgMatches
(clap::ArgMatches
wrapper for using configuration file and environment variables) - mod.rs ->
Args
(command line arguments) - parser.rs ->
ArgParser
(helper for parsing arguments)
- matches.rs ->
- edit
- mod.rs ->
ImageOps
(contains image operations related functions such ascrop
,resize
androtate
) - settings.rs ->
ImageSettings
,ColorSettings
,EditSettings
- mod.rs ->
- file
- format.rs ->
FileFormat
(enum for file formats) - info.rs ->
FileInfo
(enum for adding information to the file name) - mod.rs ->
File
(path + format) - settings.rs ->
SaveSettings
- format.rs ->
- gif
- encoder.rs ->
Encoder
(trait that GIF encoders implement) - mod.rs ->
GifEncoder
(default GIF encoder) - ski.rs ->
GifskiEncoder
(gifski encoder, enabled with--gifski
flag)
- encoder.rs ->
- image
- geometry.rs ->
Geometry
(x + y + width + height) - mod.rs ->
Image
(main image type) - padding.rs ->
Padding
(top + right + bottom + left) - settings.rs ->
PngSettings
,JpgSettings
,PnmSettings
- geometry.rs ->
- record
- fps.rs ->
FpsClock
(FPS controller) - mod.rs ->
RecordResult
,Recorder
- settings.rs ->
RecordSettings
- fps.rs ->
- util
- command.rs ->
Command
(for executing OS commands) - keys.rs ->
ActionKeys
,CancelKeys
,KeyType
(parser and checker) - logger.rs ->
Logger
(for initializing the logger) - mod.rs -> module declarations
- state.rs ->
InputState
(checks the pressed keys)
- command.rs ->
- view
- mod.rs ->
ImageViewer
- settings.rs ->
ViewSettings
- mod.rs ->
- window
- ws
- x11
- display.rs ->
Display
(X11 display wrapper with methods likeget_window
andselect_window
) - mod.rs ->
WindowSystem
(implementsAccess
trait for X11) - window.rs ->
Window
(X11 window wrapper with methods likeget_geometry
andget_name
)
- display.rs ->
There are two crucial traits in src/window/mod.rs that need to be implemented for menyoki to function.
Access
trait must be implemented for accessing the window system and getting a Window.
/* Window system functions for accessing a window */
pub trait Access<'a, Window: Capture + Send + Sync + Copy + Debug + 'static> {
fn init(settings: &'a AppSettings<'a>) -> Option<Self>
where
Self: Sized;
fn get_window(&mut self) -> Option<Window>;
}
As seen in the Access
' definition, the Window that get_window
provides must also implement Capture + Send + Sync + Copy + Debug
with the 'static
lifetime for thread safety.
Capture
trait contains methods for getting an Image, showing a countdown on the window or the console and, releasing the captured window.
/* Window methods for capturing an image */
pub trait Capture {
fn get_image(&self) -> Option<Image>;
fn show_countdown(&self);
fn release(&self);
}
As a reference: see src/x11/mod.rs (for Access
implementation), src/x11/window.rs (for Capture
implementation), and src/ws/* (for implementation templates).
The rest of the modules/functions are not platform-dependent (abstracted) so they are expected to work properly.
If you're considering to contribute, please see the Contribution Guidelines.