Expand description
This crate allows execution of CLI commands on Arista EOS switches.
§Features
blocking
(default) blocking API.async
adds async (via tokio runtime) support.
§Example using unix sockets
The UDS client is one shot, and run
consumes the client.
let result = ClientBuilder::unix_socket()
.build_blocking()?
.run(&["show clock", "show aliases"], ResultFormat::Json)?;
match result {
Response::Result(v) => println!("{v:?}"),
Response::Error {
message,
code,
errors,
} => println!("error code: {code}, message: {message}, outputs: {errors:#?}"),
};
§Example using HTTP
The HTTP(S) client can be reused to run multiple sets of commands.
let result = ClientBuilder::unix_http("localhost")
.set_authentication("admin".to_owned(), "pass".to_owned())
.build_blocking()
.run(&["show clock", "show aliases"], ResultFormat::Json)?;
match result {
Response::Result(v) => println!("{v:?}"),
Response::Error {
message,
code,
errors,
} => println!("error code: {code}, message: {message}, outputs: {errors:#?}"),
};
§Example using HTTPS
let result = ClientBuilder::unix_http("localhost")
.enable_https()
.set_authentication("admin".to_owned(), "pass".to_owned())
.build_blocking()
.run(&["show clock", "show aliases"], ResultFormat::Json)?;
match result {
Response::Result(v) => println!("{v:?}"),
Response::Error {
message,
code,
errors,
} => println!("error code: {code}, message: {message}, outputs: {errors:#?}"),
};
Structs§
- Client
Builder - Builds a client to connect to eAPI.
Enums§
- Error
- The errors returned by the library.
- Response
- Commands execution response.
- Result
Format - Format of the commands output.
Traits§
- Runner
- Commands runner. Clients implement this trait.
Functions§
- eapi_
run Deprecated - Runs commands via eAPI and returns the results.