lib.rs

Overview

This file serves as the main entry point for initializing the SDK client in the project. It provides a public function to create and configure a ClientContext instance used for interacting with the TVM client network. Additionally, it exposes several modules related to web integration, default configurations, helper utilities, and schema definitions that support the SDK's operations.


Modules


Functions

init_sdk

pub fn init_sdk(api_url: Option<String>) -> anyhow::Result<Arc<ClientContext>>

Description

Initializes the SDK's client context by configuring and creating a ClientContext object. This function optionally accepts a custom API URL to override the default network endpoints.

Parameters

Returns

Usage Example

use std::sync::Arc;

fn main() -> anyhow::Result<()> {
    let sdk_client: Arc<ClientContext> = lib::init_sdk(Some("https://api.example.com".to_string()))?;
    // Use sdk_client for network operations
    Ok(())
}

Implementation Details


Dependencies and Interactions

This file encapsulates the creation and configuration logic for the SDK client and serves as a foundation for the rest of the SDK's modules (web, defaults, helpers, and schema). Other parts of the application will import and use the init_sdk function to initialize network communications.


Mermaid Diagram: Structure and Workflow

flowchart TD
A[lib.rs] --> B[init_sdk]
A --> C[web module]
A --> D[defaults module]
A --> E[helpers module]
A --> F[schema module]
B --> G[Create endpoints vector]
B --> H[Build ClientConfig]
H --> I[NetworkConfig with endpoints]
B --> J[Create ClientContext]
J --> K[Return Arc<ClientContext>]
style A fill:#f9f,stroke:#333,stroke-width:2px
style B fill:#bbf,stroke:#333
style C fill:#eef,stroke:#333
style D fill:#eef,stroke:#333
style E fill:#eef,stroke:#333
style F fill:#eef,stroke:#333
style G fill:#afa,stroke:#333
style H fill:#afa,stroke:#333
style I fill:#afa,stroke:#333
style J fill:#afa,stroke:#333
style K fill:#afa,stroke:#333

This flowchart illustrates the main function init_sdk and its steps, along with the modules exposed by this file. It highlights how the function processes the optional API URL to create network configuration and initializes the client context.