Struct Mta

Source
pub struct Mta {
    pub ip: String,
    pub port: u16,
    pub auth: Auth,
    pub http: bool,
}
Expand description

A struct representing the configuration for making requests to the MTA service.

Fields§

§ip: String

The IP address of the MTA server.

§port: u16

The port number of the MTA server.

§auth: Auth

The authentication credentials for accessing the MTA server.

§http: bool

Determines whether HTTP or HTTPS should be used for requests.

Implementations§

Source§

impl Mta

Source

pub fn new(ip: String, port: u16, auth: Auth, http: bool) -> Mta

Creates a new Mta instance.

§Arguments
  • ip - The IP address of the MTA server.
  • port - The port number of the MTA server.
  • auth - Authentication credentials for accessing the MTA server.
  • http - Whether to use HTTP (true) or HTTPS (false) for requests.
§Example
 use mta_sdk::client;

 let auth = client::Auth {
     username: "user".to_string(),
     password: "pass".to_string(),
 };

 let mta = client::Mta::new("127.0.0.1".to_string(), 22005, auth, true);
Source

pub async fn call( &self, resource: &str, function: &str, args: Vec<String>, ) -> Result<String, Errors>

Makes a remote call to the MTA service.

This method sends a POST request to the specified resource and function on the MTA server, passing the provided arguments.

§Arguments
  • resource - The resource to call.
  • function - The function to invoke.
  • args - The arguments for the function call.
§Returns

Returns a Result containing the response text if the request is successful, or an Errors enum if an error occurs during the request.

§Errors

Returns an HTTP404ERROR variant of the Errors enum if there is a request error.

§Example
use mta_sdk::client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let auth = client::Auth {
        username: "user".to_string(),
        password: "pass".to_string(),
    };

    let mta_instance = client::Mta::new("127.0.0.1".to_string(), 22005, auth, true);
    let response = mta_instance.call("resource", "function", vec!["arg1".to_string()]).await?;
    println!("Response: {}", response);

    Ok(())
}
Source

pub fn get_uri(&self) -> String

Returns the URI based on the configured HTTP/HTTPS setting.

§Example
use mta_sdk::client;

let auth = client::Auth {
    username: "user".to_string(),
    password: "pass".to_string(),
};

let instance = client::Mta::new("127.0.0.1".to_string(), 22005, auth, true);

let uri = instance.get_uri();
println!("URI: {}", uri);

Auto Trait Implementations§

§

impl Freeze for Mta

§

impl RefUnwindSafe for Mta

§

impl Send for Mta

§

impl Sync for Mta

§

impl Unpin for Mta

§

impl UnwindSafe for Mta

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,