ShadowFile

Struct ShadowFile 

Source
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: Payload

Implementations§

Source§

impl ShadowFile

Source

pub fn name(&self) -> &str

Source

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}
Source

pub fn bytes<T: Into<Bytes>>(name: String, data: T) -> Self

Trait Implementations§

Source§

impl Clone for ShadowFile

Source§

fn clone(&self) -> ShadowFile

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ShadowFile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AbiExample for T

Source§

default fn example() -> T

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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,