|
@@ -14,7 +14,6 @@ use linear_map::LinearMap;
|
|
|
use core::mercury::MercuryError;
|
|
|
use core::session::Session;
|
|
|
use core::spotify_id::{FileId, SpotifyId};
|
|
|
-use core::util::StrChunksExt;
|
|
|
|
|
|
pub use protocol::metadata::AudioFile_Format as FileFormat;
|
|
|
|
|
@@ -215,3 +214,29 @@ impl Metadata for Artist {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+struct StrChunks<'s>(&'s str, usize);
|
|
|
+
|
|
|
+trait StrChunksExt {
|
|
|
+ fn chunks(&self, size: usize) -> StrChunks;
|
|
|
+}
|
|
|
+
|
|
|
+impl StrChunksExt for str {
|
|
|
+ fn chunks(&self, size: usize) -> StrChunks {
|
|
|
+ StrChunks(self, size)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+impl<'s> Iterator for StrChunks<'s> {
|
|
|
+ type Item = &'s str;
|
|
|
+ fn next(&mut self) -> Option<&'s str> {
|
|
|
+ let &mut StrChunks(data, size) = self;
|
|
|
+ if data.is_empty() {
|
|
|
+ None
|
|
|
+ } else {
|
|
|
+ let ret = Some(&data[..size]);
|
|
|
+ self.0 = &data[size..];
|
|
|
+ ret
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|