vieter/src/web/response/response.v

35 lines
731 B
Coq
Raw Normal View History

2022-04-06 22:41:19 +02:00
module response
2023-02-08 11:00:17 +01:00
pub struct Response[T] {
pub:
2022-04-06 22:41:19 +02:00
message string
data T
}
2022-04-07 11:58:05 +02:00
// new_response constructs a new Response<String> object with the given message
// & an empty data field.
2023-02-08 11:00:17 +01:00
pub fn new_response(message string) Response[string] {
return Response[string]{
2022-04-06 22:41:19 +02:00
message: message
data: ''
}
}
// new_data_response[T] constructs a new Response<T> object with the given data
2022-04-07 11:58:05 +02:00
// & an empty message field.
2023-02-08 11:00:17 +01:00
pub fn new_data_response[T](data T) Response[T] {
return Response[T]{
2022-04-06 22:41:19 +02:00
message: ''
data: data
}
}
// new_full_response[T] constructs a new Response<T> object with the given
2022-04-07 11:58:05 +02:00
// message & data.
2023-02-08 11:00:17 +01:00
pub fn new_full_response[T](message string, data T) Response[T] {
return Response[T]{
2022-04-06 22:41:19 +02:00
message: message
data: data
}
}