opentalk_client_shared/client/rest_client.rs
1// SPDX-FileCopyrightText: OpenTalk GmbH <mail@opentalk.eu>
2//
3// SPDX-License-Identifier: EUPL-1.2
4
5use std::error::Error;
6
7use url::Url;
8
9use crate::ApiError;
10
11/// A trait representing a client which can communicate with an OpenTalk instance via REST.
12pub trait RestClient {
13 /// The errors which may occur for this client.
14 type Error: Error + Send + Sync + 'static;
15
16 /// Get the URL for the endpoint for the client.
17 ///
18 /// This method adds the base url including hostname for the client's target instance.
19 ///
20 /// # Errors
21 ///
22 /// The error that can be returned by the method will usually indicate that
23 /// parsing the generated URL string into a [Url] failed.
24 fn rest_endpoint(&self, endpoint: &str) -> Result<Url, ApiError<Self::Error>>;
25}