I want to write a client to an api and want to seperate the different namespaces in different clients which would have the operations for each namespace.
They all share the same access code which the user could pass in to the constructor of the overall api client, the client then passes it to the inner clients for the specific namespaces. I thought of using a Cow<'a, str> for the inner clients since the access_code should be the same for all client and shouldn't be modified by the InnerClient. I am having trouble working out the lifetimes when initializing the client with a String.
-
Simplest with String This one works and doesn't need lifetimes but duplicates the string where it's not really necessary.
-
With Cow<'a, str> I believe would share the same underlying string but having trouble working out the lifetimes.
Am I going about this the right way or is there a better way of doing this?