aboutsummaryrefslogtreecommitdiff
path: root/vendor/miette-derive/src/diagnostic_arg.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
committerValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
commit1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch)
tree7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/miette-derive/src/diagnostic_arg.rs
parent5ecd8cf2cba827454317368b68571df0d13d7842 (diff)
downloadfparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz
fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/miette-derive/src/diagnostic_arg.rs')
-rw-r--r--vendor/miette-derive/src/diagnostic_arg.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/vendor/miette-derive/src/diagnostic_arg.rs b/vendor/miette-derive/src/diagnostic_arg.rs
new file mode 100644
index 0000000..bade6f0
--- /dev/null
+++ b/vendor/miette-derive/src/diagnostic_arg.rs
@@ -0,0 +1,42 @@
+use syn::parse::{Parse, ParseStream};
+
+use crate::code::Code;
+use crate::forward::Forward;
+use crate::help::Help;
+use crate::severity::Severity;
+use crate::url::Url;
+
+pub enum DiagnosticArg {
+ Transparent,
+ Code(Code),
+ Severity(Severity),
+ Help(Help),
+ Url(Url),
+ Forward(Forward),
+}
+
+impl Parse for DiagnosticArg {
+ fn parse(input: ParseStream) -> syn::Result<Self> {
+ let ident = input.fork().parse::<syn::Ident>()?;
+ if ident == "transparent" {
+ // consume the token
+ let _: syn::Ident = input.parse()?;
+ Ok(DiagnosticArg::Transparent)
+ } else if ident == "forward" {
+ Ok(DiagnosticArg::Forward(input.parse()?))
+ } else if ident == "code" {
+ Ok(DiagnosticArg::Code(input.parse()?))
+ } else if ident == "severity" {
+ Ok(DiagnosticArg::Severity(input.parse()?))
+ } else if ident == "help" {
+ Ok(DiagnosticArg::Help(input.parse()?))
+ } else if ident == "url" {
+ Ok(DiagnosticArg::Url(input.parse()?))
+ } else {
+ Err(syn::Error::new(
+ ident.span(),
+ "Unrecognized diagnostic option",
+ ))
+ }
+ }
+}