Crates.io | rusty_weed |
lib.rs | rusty_weed |
version | 0.1.3 |
source | src |
created_at | 2023-03-30 18:54:57.321128 |
updated_at | 2023-04-02 15:03:19.355707 |
description | A SeaweedFS client implementation. |
homepage | |
repository | https://github.com/kerzeld/rusty_weed |
max_upload_size | |
id | 825345 |
size | 30,089 |
A client implementation in rust for SeaweedFS. Written with the help of reqwest as http client and serde for serialization/deserialization.
let master = Master {
host: MASTER_HOST.to_string(),
port: Some(MASTER_PORT),
};
let options: AssignKeyOptions = Default::default();
let master_resp = master.assign_key(&Some(options)).await;
let fid: FID;
let volume: Volume;
match master_resp {
Ok(x) => {
println!("Address {}", x.location.url);
volume = Volume::from_str(&x.location.url).unwrap();
fid = x.fid;
}
_ => panic!("failed to assign key"),
}
let data = Bytes::from("Hello World!");
let resp = volume.upload_file_bytes(&fid, &data, &None).await;
let master = Master {
host: MASTER_HOST.to_string(),
port: Some(MASTER_PORT),
};
let options: AssignKeyOptions = Default::default();
let master_resp = master.assign_key(&Some(options)).await;
let fid: FID;
let volume: Volume;
match master_resp {
Ok(x) => {
println!("Address {}", x.location.url);
volume = Volume::from_str(&x.location.url).unwrap();
fid = x.fid;
}
_ => panic!("failed to assign key"),
}
let form = Form::new().part("file", Part::text("Hello World!").file_name("hello.txt").mime_str("text/plain").unwrap());
let file_resp = volume.upload_file_form(&fid, form, &None).await;