volcengine_rust_sdk/service/vpc/mod.rs
1/*
2 * @Author: Jerry.Yang
3 * @Date: 2024-10-29 17:23:24
4 * @LastEditors: Jerry.Yang
5 * @LastEditTime: 2025-02-06 14:37:16
6 * @Description: Module for managing VPCs and subnets using the Volcengine SDK.
7 */
8use crate::volcengine::client::client;
9use crate::volcengine::error::error;
10use crate::volcengine::session::session;
11use std::future::Future;
12use volcengine_sdk_protobuf::protobuf::vpc_subnet;
13use volcengine_sdk_protobuf::protobuf::vpc_vpc;
14
15// Import modules for various VPC operations
16mod api_describe_subnets;
17mod api_describe_subnets_model;
18mod api_describe_vpcs;
19mod api_describe_vpcs_model;
20pub mod service_vpc;
21mod tests;
22
23/// Defines the VpcService trait, providing methods for various VPC operations.
24/// This trait encapsulates the functionality required to interact with the Volcengine VPC service.
25pub trait VpcService {
26 /// Creates a new VPC service instance from a given session.
27 ///
28 /// # Arguments
29 /// - `session`: The session object containing the necessary configuration and credentials.
30 ///
31 /// # Returns
32 /// - `Result<Vpc, error::Error>`: On success, returns a new instance of the Vpc struct.
33 /// On failure, returns an error indicating the cause of the failure.
34 fn new_vpc(session: session::Session) -> Result<Vpc, error::Error>;
35
36 /// Describes VPCs.
37 ///
38 /// # Arguments
39 /// - `&self`: Reference to the current VPC service instance.
40 /// - `request`: The request structure containing the parameters for describing VPCs.
41 ///
42 /// # Returns
43 /// - `impl Future<Output = Result<vpc_vpc::DescribeVpcsResp, error::Error>>`: On success, returns a future that resolves to the response from the VPC service.
44 /// On failure, returns an error indicating the cause of the failure.
45 fn new_describe_vpcs(
46 &self,
47 request: vpc_vpc::DescribeVpcsReq,
48 ) -> impl Future<Output = Result<vpc_vpc::DescribeVpcsResp, error::Error>>;
49
50 /// Describes VPC subnets.
51 ///
52 /// # Arguments
53 /// - `&self`: Reference to the current VPC service instance.
54 /// - `request`: The request structure containing the parameters for describing VPC subnets.
55 ///
56 /// # Returns
57 /// - `impl Future<Output = Result<vpc_subnet::DescribeSubnetsResp, error::Error>>`: On success, returns a future that resolves to the response from the VPC service.
58 /// On failure, returns an error indicating the cause of the failure.
59 fn new_describe_subnets(
60 &self,
61 request: vpc_subnet::DescribeSubnetsReq,
62 ) -> impl Future<Output = Result<vpc_subnet::DescribeSubnetsResp, error::Error>>;
63}
64
65/// Represents the VPC service, encapsulating the client information required to interact with the Volcengine VPC service.
66#[derive(Debug, Clone)]
67pub struct Vpc {
68 /// The client used to make requests to the Volcengine VPC service.
69 client: client::Client,
70}