Skip to content

Commit 0b6b98e

Browse files
authored
Merge pull request kstep#35 from neodc/add-stickers_map
Add stickers_map
2 parents fd15ce6 + 1284d9b commit 0b6b98e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/client.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use status::{ReplayGain, Status};
2222
use std::convert::From;
2323
use std::io::{BufRead, Lines, Read, Write};
2424
use std::net::{TcpStream, ToSocketAddrs};
25+
use std::collections::HashMap;
2526
use sticker::Sticker;
2627
use version::Version;
2728

@@ -567,6 +568,17 @@ impl<S: Read + Write> Client<S> {
567568
.map(|v| v.into_iter().map(|b| b.splitn(2, '=').nth(1).map(|s| s.to_owned()).unwrap()).collect())
568569
}
569570

571+
/// List all stickers from a given object in a map, identified by type and uri
572+
pub fn stickers_map(&mut self, typ: &str, uri: &str) -> Result<HashMap<String, String>> {
573+
self.run_command("sticker list", (typ, uri))
574+
.and_then(|_| self.read_list("sticker"))
575+
.map(|v| v.into_iter().map(|b| {
576+
let mut iter = b.splitn(2, '=');
577+
578+
(iter.next().unwrap().to_owned(), iter.next().unwrap().to_owned())
579+
}).collect())
580+
}
581+
570582
/// List all (file, sticker) pairs for sticker name and objects of given type
571583
/// from given directory (identified by uri)
572584
pub fn find_sticker(&mut self, typ: &str, uri: &str, name: &str) -> Result<Vec<(String, String)>> {

0 commit comments

Comments
 (0)