commit bca276c07c2f110f568d53328016f78b4433a1ab
parent 9f53b7ce38635062b2e45bb287d57dd5d744aa10
Author: Antoine A <>
Date: Mon, 14 Oct 2024 17:51:55 +0200
rust template
Diffstat:
7 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/gnu-taler-error-codes/.gitignore b/gnu-taler-error-codes/.gitignore
@@ -5,3 +5,4 @@
*.ts
taler_error_codes.py
*.go
+*.rs
diff --git a/gnu-taler-error-codes/Makefile b/gnu-taler-error-codes/Makefile
@@ -4,7 +4,8 @@ FILES=taler_error_codes.h \
taler_error_codes.py \
taler_error_codes.kt \
taler_error_codes.go \
- taler_error_codes.rst
+ taler_error_codes.rs \
+ taler_error_codes.rst
all: check $(FILES)
@@ -79,4 +80,13 @@ taler_error_codes.rst.tmp: combined.tmp rst.template
taler_error_codes.rst: rst.header taler_error_codes.rst.tmp rst.footer
cat $^ > $@
+taler_error_codes.rs_enum.tmp: combined.tmp rs.enum_template
+ ../format.sh rs.enum_template < combined.tmp > $@
+
+taler_error_codes.rs_impl.tmp: combined-escaped.tmp rs.impl_template
+ ../format.sh rs.impl_template < combined-escaped.tmp > $@
+
+taler_error_codes.rs: rs.header taler_error_codes.rs_enum.tmp rs.impl taler_error_codes.rs_impl.tmp rs.footer
+ cat $^ > $@
+
.PHONY: check clean distclean prep
diff --git a/gnu-taler-error-codes/rs.enum_template b/gnu-taler-error-codes/rs.enum_template
@@ -0,0 +1,2 @@
+ /** {{Description}} */
+ {{Name}} = {{Value}},
diff --git a/gnu-taler-error-codes/rs.footer b/gnu-taler-error-codes/rs.footer
@@ -0,0 +1,3 @@
+ }
+ }
+}
+\ No newline at end of file
diff --git a/gnu-taler-error-codes/rs.header b/gnu-taler-error-codes/rs.header
@@ -0,0 +1,28 @@
+/*
+ This file is part of GNU Taler
+ Copyright (C) 2024 Taler Systems SA
+
+ GNU Taler is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: LGPL3.0-or-later
+
+ Note: the LGPL does not apply to all components of GNU Taler,
+ but it does apply to this file.
+ */
+
+/// Error codes used by GNU Taler
+#[derive(Debug, Copy, Clone, PartialEq, Eq)]
+#[allow(non_camel_case_types, dead_code)]
+#[repr(u16)]
+pub enum ErrorCode {
+\ No newline at end of file
diff --git a/gnu-taler-error-codes/rs.impl b/gnu-taler-error-codes/rs.impl
@@ -0,0 +1,6 @@
+}
+
+impl ErrorCode {
+ pub fn metadata(&self) -> (u16, &'static str) {
+ use ErrorCode::*;
+ match self {
diff --git a/gnu-taler-error-codes/rs.impl_template b/gnu-taler-error-codes/rs.impl_template
@@ -0,0 +1 @@
+ {{Name}} => ({{HttpStatus_Value}}, "{{Description}}"),