#azure-sdk #s3 #microsoft #aws #azure-storage #access #break

azure-sdk-rust

**正在非常快速的开发中** 很可能会破坏!微软Azure SDK for Rust。最初设计得尽可能接近aws-sdk-rust,但设计决策发生了变化,使其更特定于Azure。将使用一个抽象库来管理两个之间的差异,以供需要跨云访问的人使用。

2个版本

使用旧的Rust 2015

0.1.2 2017年3月10日
0.1.1 2017年3月10日

#15 in #break

Apache-2.0

1MB
2K SLoC

包含 (WOFF字体,120KB) docs/Heuristica-Italic.woff,(WOFF字体,90KB) docs/FiraSans-Medium.woff,(WOFF字体,92KB) docs/FiraSans-Regular.woff,(WOFF字体,56KB) docs/SourceCodePro-Regular.woff,(WOFF字体,56KB) docs/SourceCodePro-Semibold.woff,(WOFF字体,49KB) docs/SourceSerifPro-Bold.woff 和更多

微软Azure SDK for Rust

简介

微软Azure通过REST API公开其技术。这些API可以从任何语言轻松消费(优点)但类型较弱。

免责声明

此项目受到了azure_sdk_for_rust crate的很大影响,但代码已经有一年多没有更新了。

请在此期间或下一个版本发布点之前不要使用

示例

您可以在测试部分(就Azure而言,尚不存在)和main.rs文件中找到示例。这里有一个示例

main.rs

extern crate azure_sdk_rust;
extern crate chrono;
#[macro_use]
extern crate mime;

use azure_sdk_for_rust::azure::core::lease::{LeaseState, LeaseStatus};
use azure_sdk_for_rust::azure::storage::client::Client;
use azure_sdk_for_rust::azure::storage::blob::{Blob, BlobType, PUT_OPTIONS_DEFAULT};
use azure_sdk_for_rust::azure::storage::container::{Container, PublicAccess, LIST_CONTAINER_OPTIONS_DEFAULT};

use chrono::UTC;

use mime::Mime;

fn main() {
  let azure_storage_account = &"azure_storage_account";
  let azure_storage_key= &"azure_storage_key";

  // create the client struct. The third argument, if false, forces to use
  // http instead of https. It's useful if you have trouble compiling
  // hyper with openSSL activated.
  let client = Client::new(azure_storage_account, azure_storage_key, false);


  // This call will list your containers.
  let containers = Container::list(&client, &LIST_CONTAINER_OPTIONS_DEFAULT).unwrap();
  println!("{:?}", containers);

  let container_name = "rust";
  // This call will create a new Azure Container called "wow"
  // with public blob access (see https://msdn.microsoft.com/en-us/library/azure/dd179468.aspx)
  // if it doesn't exist already.

  let cont = containers.iter().find(|x| x.name == container_name);
  if let None = cont {
  	Container::create(&client, container_name, PublicAccess::Blob).unwrap();
  }

  // this code will upload a file to the container just created.
  {
	use std::fs::metadata;
	use std::fs::File;

	let file_name: &'static str = "C:\\temp\\from_rust.txt";
	let container_name: &'static str = "wow";

	let metadata = metadata(file_name).unwrap();
	let mut file = File::open(file_name).unwrap();

	let new_blob = Blob {
		name: "from_rust.txt".to_owned(),
        container_name: container_name.to_owned(),
		snapshot_time: None,
		last_modified: UTC::now(),
		etag: "".to_owned(),
		content_length: metadata.len(),
		content_type: "application/octet-stream".parse::<Mime>().unwrap(),
		content_encoding: None,
		content_language: None,
		content_md5: None,
		cache_control: None,
		x_ms_blob_sequence_number: None,
		blob_type: BlobType::BlockBlob,
		lease_status: LeaseStatus::Unlocked,
		lease_state: LeaseState::Available,
		lease_duration: None,
		copy_id: None,
		copy_status: None,
		copy_source: None,
		copy_progress: None,
		copy_completion: None,
		copy_status_description: None,
	};

	new_blob.put(&client,
        &PUT_OPTIONS_DEFAULT,
		 Some((&mut file, metadata.len())))
		.unwrap();
  }


  // This code will look for the "todelete" container and
  // remove from Azure.
  let mut to_delete = containers.iter_mut().find(|x| x.name == "todelete").unwrap();
  to_delete.delete(&client).unwrap();
  println!("{:?} deleted!", to_delete);
}

存储容器

从azure_sdk_for_rust项目提升

方法 URL
创建容器 https://msdn.microsoft.com/en-us/library/azure/dd179468.aspx
列出容器 https://msdn.microsoft.com/en-us/library/azure/dd179352.aspx
删除容器 https://msdn.microsoft.com/en-us/library/azure/dd179408.aspx

存储块

方法 URL
列出块 https://msdn.microsoft.com/en-us/library/azure/dd135734.aspx
获取块 https://msdn.microsoft.com/en-us/library/azure/dd179440.aspx
放置块 https://msdn.microsoft.com/en-us/library/azure/dd179451.aspx
放置块页面 https://msdn.microsoft.com/en-us/library/azure/dd179451.aspx
清除块页面 https://msdn.microsoft.com/en-us/library/azure/dd179451.aspx
放置块 https://msdn.microsoft.com/en-us/library/azure/dd135726.aspx
租赁块 https://msdn.microsoft.com/library/azure/ee691972.aspx

事件中心

方法 URL
发送事件 https://msdn.microsoft.com/en-us/library/azure/dn790664.aspx

许可证

本项目根据Apache许可证,版本2.0发布。

依赖关系

~12MB
~221K SLoC