Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch server function #5

Open
mrghosti3 opened this issue Jun 22, 2023 · 1 comment
Open

Watch server function #5

mrghosti3 opened this issue Jun 22, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@mrghosti3
Copy link
Owner

Implement functionality to get notifications of file changes and update NBT data (and probably if possible, YML if NBT changes). It should be easily enabled via CLI and opt-in. Flags could --watch with alias -w.

For now possible solution for this is to use inotify (7) syscall via nix crate.

mrghosti3 added a commit that referenced this issue Jun 22, 2023
This commit introduces mainly the option to start a watch server for
following changes in YML file and then recompiling the NBT file. This
works by using a unix syscalls `inotify(7)`. But it also includes other
changes which are more touched upon in the next sections.

Module `err` contains a wrapper enum `MyError` which simply wraps around
various errors that occur at runtime. For now, when errors appear, they
are just sent to main function where they are handled via `.expect`. But
this may change in the future as errors should be printed in more user
friendly text.

Module `state` is used for storing everything concerning State machine.
It contains a simple `State` struct that stores opened NBT and YML
files with helper functions to reset cursor position before generating
buffered reader/writer. For now the `STATE` is stored in stack of `MAIN`
function, but storing in `GLOBAL` state should be revisited.

Module `util` contains all of the helper functions that use to exist in
crate root. Only helper functions are contained there to abstract
implementation details from `fn main`.

Changes are mostly in experimental stage and conversion may improve
between NBT and YML formats.

Initial stage for #5
@mrghosti3 mrghosti3 self-assigned this Sep 13, 2023
@mrghosti3 mrghosti3 added the enhancement New feature or request label Sep 13, 2023
@mrghosti3
Copy link
Owner Author

Using inotify it calls events on file multiple times. Could be the case that the number is correlated to number of blocks have to written into disk.

@mrghosti3 mrghosti3 mentioned this issue Mar 9, 2024
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant