pub struct ShadowFile {
pub name: String,
pub data: Payload,
/* private fields */
}Expand description
ShadowFile is the combination of a file name and a Payload.
Fields§
§name: String§data: PayloadImplementations§
Source§impl ShadowFile
impl ShadowFile
pub fn name(&self) -> &str
Sourcepub fn file<T: AsRef<Path>>(name: String, path: T) -> Self
pub fn file<T: AsRef<Path>>(name: String, path: T) -> Self
Examples found in repository?
examples/end_to_end.rs (line 36)
9async fn main() {
10 // Get keypair
11 let keypair_file: String = std::env::args()
12 .skip(1)
13 .next()
14 .expect("no keypair file provided");
15 let keypair: Keypair = read_keypair_file(keypair_file).expect("failed to read keypair file");
16 println!("loaded keypair");
17
18 // Initialize client
19 let client = ShadowDriveClient::new(keypair, SOLANA_MAINNET_RPC);
20 println!("initialized client");
21
22 // Create account
23 let response = client
24 .create_storage_account(
25 "test",
26 Byte::from_bytes(2_u128.pow(20)),
27 shadow_drive_sdk::StorageAccountVersion::V2,
28 )
29 .await
30 .expect("failed to create storage account");
31 let account = Pubkey::from_str(&response.shdw_bucket.unwrap()).unwrap();
32 println!("created storage account");
33
34 // Upload files
35 let files: Vec<ShadowFile> = vec![
36 ShadowFile::file("alpha.txt".to_string(), "./examples/files/alpha.txt"),
37 ShadowFile::file(
38 "not_alpha.txt".to_string(),
39 "./examples/files/not_alpha.txt",
40 ),
41 ];
42 let response = client
43 .store_files(&account, files.clone())
44 .await
45 .expect("failed to upload files");
46 println!("uploaded files");
47 for url in &response.finalized_locations {
48 println!(" {url}")
49 }
50 // Try editing
51 for file in files {
52 let response = client
53 .edit_file(&account, file)
54 .await
55 .expect("failed to upload files");
56 assert!(!response.finalized_location.is_empty(), "failed edit");
57 println!("edited file: {}", response.finalized_location);
58 }
59
60 // Delete files
61 for url in response.finalized_locations {
62 client
63 .delete_file(&account, url)
64 .await
65 .expect("failed to delete files");
66 }
67 println!("deleted files");
68
69 // Delete account
70 client
71 .delete_storage_account(&account)
72 .await
73 .expect("failed to delete storage account");
74 println!("deleted account");
75}pub fn bytes<T: Into<Bytes>>(name: String, data: T) -> Self
Trait Implementations§
Source§impl Clone for ShadowFile
impl Clone for ShadowFile
Source§fn clone(&self) -> ShadowFile
fn clone(&self) -> ShadowFile
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !Freeze for ShadowFile
impl RefUnwindSafe for ShadowFile
impl Send for ShadowFile
impl Sync for ShadowFile
impl Unpin for ShadowFile
impl UnwindSafe for ShadowFile
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more