-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: filemanager sea-orm entities #357
Conversation
ea741a7
to
5cb988a
Compare
let generated = quote!( | ||
// Auto-generated by the filemanager build script. | ||
#[path = #path] | ||
pub mod entities; | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required to be able to include the module in the filemanager
crate using include!(concat!(env!("OUT_DIR"), "/entities.rs"))
. My IDE is able to pick up these modules okay, AFAIK vscode should work too.
/// Create an error with caller location to print error information. | ||
#[track_caller] | ||
fn from(error_kind: ErrorKind) -> Self { | ||
let loc = Location::caller(); | ||
|
||
if let Some(path) = workspace_path() { | ||
if let Ok(source) = read_to_string(path.join(loc.file())) { | ||
let offset = SourceOffset::from_location( | ||
source.as_str(), | ||
loc.line() as usize, | ||
loc.column() as usize, | ||
); | ||
|
||
return Self::new( | ||
error_kind, | ||
Some(NamedSource::new(loc.file(), source)), | ||
Some(offset), | ||
); | ||
} | ||
} | ||
|
||
Self::new(error_kind, None, None) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using miette for nicer compile/build error printing. #[track_caller]
is useful to print line information about where an error occurred, similar to the Rust compiler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand the code correctly, filemanager-build/src/entities.rs
generates ... entities.rs
that will be include!
-d on mod.rs
... for easier source code navigation I would prefix with gen_
or similar (i.e gen_entities.rs
), otherwise it gets confusing what codegens what (entities.rs
codegenerating another entities.rs
somewhere else?) :-S
If filemanager-build/src/entities.rs is the generated file, I'd put a header that states that: Autogenerated file, see the other file gen_entities.rs for its source/generation
.
That's a good call, |
Either way works, just make it clear which generates and which is generated ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Closes #314
Changes
filemanager-build
crate is used for better code organisation.Leaving this as a draft for now until the phase 1 deployment is complete.