vieter/src/response.v

35 lines
731 B
Coq
Raw Normal View History

2022-04-06 22:41:19 +02:00
module response
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.
2022-04-06 22:41:19 +02:00
pub fn new_response(message string) Response<string> {
return Response<string>{
message: message
data: ''
}
}
2022-04-07 11:58:05 +02:00
// new_data_response<T> constructs a new Response<T> object with the given data
// & an empty message field.
2022-04-06 22:41:19 +02:00
pub fn new_data_response<T>(data T) Response<T> {
return Response<T>{
message: ''
data: data
}
}
2022-04-07 11:58:05 +02:00
// new_full_response<T> constructs a new Response<T> object with the given
// message & data.
2022-04-06 22:41:19 +02:00
pub fn new_full_response<T>(message string, data T) Response<T> {
return Response<T>{
message: message
data: data
}
}