Xenon for Rust
This crate contains Rust bindings to the Xenon middleware (gRPC).
Documentation
Usage
The interface is kept, as much as possible, similar to Xenon's Java API.
use anyhow::Result;
use xenon::credentials::Credential;
use xenon::storage::{FileSystem, FileSystemPath};
#[tokio::main]
async fn main() -> Result<()> {
let location = "remote-server:22";
let credential = Credential::new_password("username", "password");
let xenon_endpoint = "http://localhost:50051";
let mut filesystem = FileSystem::create(
"sftp",
location,
credential,
xenon_endpoint,
None,
).await?;
let example_file = "./example.txt";
if !filesystem.exists(example_file).await? {
filesystem.create_file(example_file).await?;
}
let text = String::from("Hello, world!\n");
filesystem.append_to_file(text, example_file).await?;
filesystem.close().await?;
Ok(())
}
See the examples directory for more examples.