Skip to content

Commit

Permalink
Merge pull request #35 from neodc/add-stickers_map
Browse files Browse the repository at this point in the history
Add stickers_map
  • Loading branch information
kstep authored Apr 23, 2018
2 parents fd15ce6 + 1284d9b commit 0b6b98e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use status::{ReplayGain, Status};
use std::convert::From;
use std::io::{BufRead, Lines, Read, Write};
use std::net::{TcpStream, ToSocketAddrs};
use std::collections::HashMap;
use sticker::Sticker;
use version::Version;

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

/// List all stickers from a given object in a map, identified by type and uri
pub fn stickers_map(&mut self, typ: &str, uri: &str) -> Result<HashMap<String, String>> {
self.run_command("sticker list", (typ, uri))
.and_then(|_| self.read_list("sticker"))
.map(|v| v.into_iter().map(|b| {
let mut iter = b.splitn(2, '=');

(iter.next().unwrap().to_owned(), iter.next().unwrap().to_owned())
}).collect())
}

/// List all (file, sticker) pairs for sticker name and objects of given type
/// from given directory (identified by uri)
pub fn find_sticker(&mut self, typ: &str, uri: &str, name: &str) -> Result<Vec<(String, String)>> {
Expand Down

0 comments on commit 0b6b98e

Please sign in to comment.