Skip to content

Commit e0ab1b8

Browse files
committed
Improved api
1 parent de82ab7 commit e0ab1b8

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

discovery/examples/discovery.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ async fn main() {
1010
.init()
1111
.unwrap();
1212

13-
let name = "Librespot".to_string();
13+
let name = "Librespot";
1414
let device_id = hex::encode(Sha1::digest(name.as_bytes()));
1515

1616
let mut server = librespot_discovery::Discovery::builder(device_id)

discovery/src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,18 @@ pub enum Error {
7575

7676
impl Builder {
7777
/// Starts a new builder using the provided device id.
78-
pub fn new(device_id: String) -> Self {
78+
pub fn new(device_id: impl Into<String>) -> Self {
7979
Self {
8080
name: "Librespot".into(),
8181
device_type: DeviceType::default(),
82-
device_id,
82+
device_id: device_id.into(),
8383
port: 0,
8484
}
8585
}
8686

8787
/// Sets the name to be displayed. Default is `"Librespot"`.
88-
pub fn name(mut self, name: String) -> Self {
89-
self.name = name;
88+
pub fn name(mut self, name: impl Into<String>) -> Self {
89+
self.name = name.into();
9090
self
9191
}
9292

@@ -143,12 +143,12 @@ impl Builder {
143143

144144
impl Discovery {
145145
/// Starts a [`Builder`] with the provided device id.
146-
pub fn builder(device_id: String) -> Builder {
146+
pub fn builder(device_id: impl Into<String>) -> Builder {
147147
Builder::new(device_id)
148148
}
149149

150150
/// Create a new instance with the specified device id and default paramaters.
151-
pub fn new(device_id: String) -> Result<Self, Error> {
151+
pub fn new(device_id: impl Into<String>) -> Result<Self, Error> {
152152
Self::builder(device_id).launch()
153153
}
154154
}

0 commit comments

Comments
 (0)