11#[ macro_use]
22extern crate log;
33
4+ use azure_sdk_core:: errors:: AzureError ;
45use azure_sdk_core:: prelude:: * ;
56use azure_sdk_storage_blob:: prelude:: * ;
67use azure_sdk_storage_core:: prelude:: * ;
78use std:: error:: Error ;
9+ use std:: sync:: Arc ;
810
911#[ tokio:: main]
1012async fn main ( ) -> Result < ( ) , Box < dyn Error > > {
@@ -22,7 +24,23 @@ async fn main() -> Result<(), Box<dyn Error>> {
2224 . expect ( "please specify blob name as command line parameter" ) ;
2325
2426 let client: Box < dyn Client > = Box :: new ( client:: with_access_key ( & account, & master_key) ) ;
27+ let s_content = get_blob_box ( & client, & container, & blob) . await ?;
28+ println ! ( "blob == {:?}" , blob) ;
29+ println ! ( "s_content == {}" , s_content) ;
30+
31+ let client: Arc < dyn Client > = Arc :: new ( client:: with_access_key ( & account, & master_key) ) ;
32+ let s_content = get_blob_arc ( client, & container, & blob) . await ?;
33+ println ! ( "blob == {:?}" , blob) ;
34+ println ! ( "s_content == {}" , s_content) ;
2535
36+ Ok ( ( ) )
37+ }
38+
39+ async fn get_blob_box < ' a > (
40+ client : & ' a Box < dyn Client > ,
41+ container : & ' a str ,
42+ blob : & ' a str ,
43+ ) -> Result < String , AzureError > {
2644 trace ! ( "Requesting blob" ) ;
2745
2846 let response = client
@@ -32,9 +50,22 @@ async fn main() -> Result<(), Box<dyn Error>> {
3250 . finalize ( )
3351 . await ?;
3452
35- let s_content = String :: from_utf8 ( response. data ) ?;
36- println ! ( "blob == {:?}" , blob) ;
37- println ! ( "s_content == {}" , s_content) ;
53+ Ok ( String :: from_utf8 ( response. data ) ?)
54+ }
3855
39- Ok ( ( ) )
56+ async fn get_blob_arc < ' a > (
57+ client : Arc < dyn Client > ,
58+ container : & ' a str ,
59+ blob : & ' a str ,
60+ ) -> Result < String , AzureError > {
61+ trace ! ( "Requesting blob" ) ;
62+
63+ let response = client
64+ . get_blob ( )
65+ . with_container_name ( & container)
66+ . with_blob_name ( & blob)
67+ . finalize ( )
68+ . await ?;
69+
70+ Ok ( String :: from_utf8 ( response. data ) ?)
4071}
0 commit comments