endpoint_libs/model/service.rs
1use crate::model::EndpointSchema;
2use serde::*;
3
4/// `Service` is a struct that represents a single service in the API.
5#[derive(Debug, Serialize, Deserialize)]
6pub struct Service {
7 /// The name of the service (e.g. `user`)
8 pub name: String,
9
10 /// The ID of the service (e.g. `1`)
11 pub id: u16,
12
13 /// A list of endpoints (schemas) that the service contains (e.g. `user_endpoints::get_user_endpoints()`)
14 pub endpoints: Vec<EndpointSchema>,
15}
16
17impl Service {
18 /// Creates a new `Service` with the given name, ID and endpoints.
19 pub fn new(name: impl Into<String>, id: u16, endpoints: Vec<EndpointSchema>) -> Self {
20 Self {
21 name: name.into(),
22 id,
23 endpoints,
24 }
25 }
26}