Struct algorithmia::data::DataDir
[−]
[src]
pub struct DataDir { /* fields omitted */ }
Algorithmia Data Directory
Methods
impl DataDir
[src]
fn list(&self) -> DirectoryListing
Display Directory details if it exists
Examples
let client = Algorithmia::client("111112222233333444445555566"); let my_dir = client.dir(".my/my_dir"); let dir_list = my_dir.list(); for entry in dir_list { match entry { Ok(DataItem::File(f)) => println!("File: {}", f.to_data_uri()), Ok(DataItem::Dir(d)) => println!("Dir: {}", d.to_data_uri()), Err(err) => { println!("Error: {}", err); break; }, } };
fn create<Acl: Into<DataAcl>>(&self, acl: Acl) -> Result<()>
Create a Directory
Use DataAcl::default()
or the ReadAcl
enum to set the ACL
Examples
let client = Algorithmia::client("111112222233333444445555566"); let my_dir = client.dir(".my/my_dir"); match my_dir.create(DataAcl::default()) { Ok(_) => println!("Successfully created Directory"), Err(e) => println!("Error created directory: {}", e), };
fn delete(&self, force: bool) -> Result<DirectoryDeleted>
Delete a Directory
Examples
let client = Algorithmia::client("111112222233333444445555566"); let my_dir = client.dir(".my/my_dir"); match my_dir.delete(false) { Ok(_) => println!("Successfully deleted Directory"), Err(err) => println!("Error deleting directory: {}", err), };
fn put_file<P: AsRef<Path>>(&self, file_path: P) -> Result<()>
Upload a file to an existing Directory
Examples
let client = Algorithmia::client("111112222233333444445555566"); let my_dir = client.dir(".my/my_dir"); match my_dir.put_file("/path/to/file") { Ok(_) => println!("Successfully uploaded to: {}", my_dir.to_data_uri()), Err(err) => println!("Error uploading file: {}", err), };
fn child<T: HasDataPath>(&self, filename: &str) -> T
Instantiate DataFile
or DataDir
as a child of this DataDir
Trait Implementations
impl HasDataPath for DataDir
[src]
fn to_url(&self) -> Result<Url>
Get the API Endpoint URL for a particular data URI
fn to_data_uri(&self) -> String
Get the Algorithmia data URI a given Data Object Read more
fn parent(&self) -> Option<DataDir>
Get the parent off a given Data Object Read more
fn basename(&self) -> Option<String>
Get the basename from the Data Object's path (i.e. unix basename
) Read more
fn exists(&self) -> Result<bool>
Determine if a file or directory exists for a particular data URI Read more
impl From<DataObject> for DataDir
[src]
fn from(d: DataObject) -> Self
Performs the conversion.