|
11 | 11 |
|
12 | 12 | mod server; |
13 | 13 |
|
| 14 | +use std::borrow::Cow; |
14 | 15 | use std::io; |
15 | 16 | use std::pin::Pin; |
16 | 17 | use std::task::{Context, Poll}; |
@@ -60,19 +61,19 @@ pub enum Error { |
60 | 61 |
|
61 | 62 | impl Builder { |
62 | 63 | /// Starts a new builder using the provided device id. |
63 | | - pub fn new(device_id: String) -> Self { |
| 64 | + pub fn new(device_id: impl Into<String>) -> Self { |
64 | 65 | Self { |
65 | 66 | server_config: server::Config { |
66 | 67 | name: "Librespot".into(), |
67 | 68 | device_type: DeviceType::default(), |
68 | | - device_id, |
| 69 | + device_id: device_id.into(), |
69 | 70 | }, |
70 | 71 | port: 0, |
71 | 72 | } |
72 | 73 | } |
73 | 74 |
|
74 | 75 | /// Sets the name to be displayed. Default is `"Librespot"`. |
75 | | - pub fn name(mut self, name: String) -> Self { |
| 76 | + pub fn name(mut self, name: impl Into<Cow<'static, str>>) -> Self { |
76 | 77 | self.server_config.name = name.into(); |
77 | 78 | self |
78 | 79 | } |
@@ -130,12 +131,12 @@ impl Builder { |
130 | 131 |
|
131 | 132 | impl Discovery { |
132 | 133 | /// Starts a [`Builder`] with the provided device id. |
133 | | - pub fn builder(device_id: String) -> Builder { |
| 134 | + pub fn builder(device_id: impl Into<String>) -> Builder { |
134 | 135 | Builder::new(device_id) |
135 | 136 | } |
136 | 137 |
|
137 | 138 | /// Create a new instance with the specified device id and default paramaters. |
138 | | - pub fn new(device_id: String) -> Result<Self, Error> { |
| 139 | + pub fn new(device_id: impl Into<String>) -> Result<Self, Error> { |
139 | 140 | Self::builder(device_id).launch() |
140 | 141 | } |
141 | 142 | } |
|
0 commit comments