Giter VIP home page Giter VIP logo

Comments (5)

rylev avatar rylev commented on August 20, 2024

Yes, I don't think there's any reason to not take ownership of account and token.

from azure-sdk-for-rust.

MindFlavor avatar MindFlavor commented on August 20, 2024

Hi spektom,
client::with_bearer_token() allows borrowing and taking ownership while both client::with_access_key and client::with_azure_sas only allow borrowing. See:

pub fn with_access_key(account: &str, key: &str) -> KeyClient {

and

pub fn with_azure_sas(account: &str, sas_token: &str) -> KeyClient {

While client::with_bearer_token() allows both borrowing and taking ownership.

pub fn with_bearer_token<'a, A, BT>(account: A, bearer_token: BT) -> BearerTokenClient<'a>
where
A: Into<Cow<'a, str>>,
BT: Into<Cow<'a, str>>,

So they should behave just the same (with client::with_bearer_token() being more flexible).

For example, this borrows:

let container = std::env::args()
.nth(1)
.expect("please specify container name as command line parameter");
let blob = std::env::args()
.nth(2)
.expect("please specify blob name as command line parameter");
let client = client::with_access_key(&account, &master_key);

This example takes ownership:

let account = std::env::args()
.nth(1)
.expect("please specify the account name as first command line parameter");
let container = std::env::args()
.nth(2)
.expect("please specify the container name as second command line parameter");
let blob = std::env::args()
.nth(3)
.expect("please specify the blob name as third command line parameter");
let bearer_token = std::env::args()
.nth(4)
.expect("please specify the bearer token as fourth command line parameter");
let client = client::with_bearer_token(account, bearer_token);

But the latter works just the same if you borrow instead:

    let client = client::with_bearer_token(&account, &bearer_token);

--

Can you please provide a repro of your problem?

from azure-sdk-for-rust.

spektom avatar spektom commented on August 20, 2024

Thanks, and sorry for bothering.

from azure-sdk-for-rust.

MindFlavor avatar MindFlavor commented on August 20, 2024

Thanks, and sorry for bothering.

Don't worry, you correctly pointed out that we have uneven builders: the all should allow both borrowing and owning 👍 !

from azure-sdk-for-rust.

rylev avatar rylev commented on August 20, 2024

I somewhat disagree. I don't think allowing for the flexibility of taking either a reference or an owned value is really worth the complexity. Taking these as String instead of Cow<'a, str> would simplify the API considerably at only a very minimal potential runtime cost.

from azure-sdk-for-rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.