Skip to content

Commit

Permalink
Rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
agersant committed Oct 6, 2018
1 parent ec69a35 commit 15a10f0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 28 deletions.
1 change: 0 additions & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
write_mode = "Overwrite"
hard_tabs = true
48 changes: 25 additions & 23 deletions src/playlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ use core::clone::Clone;
use core::ops::Deref;
use diesel;
use diesel::prelude::*;
use diesel::BelongingToDsl;
use diesel::types::*;
use diesel::BelongingToDsl;
use std::path::Path;

#[cfg(test)]
use db;
use db::ConnectionSource;
use db::{playlists, playlist_songs, users};
use db::{playlist_songs, playlists, users};
use errors::*;
use index::{self, Song};
use vfs::VFSSource;
use errors::*;

#[derive(Insertable)]
#[table_name="playlists"]
#[table_name = "playlists"]
struct NewPlaylist {
name: String,
owner: i32,
Expand All @@ -27,29 +27,30 @@ pub struct User {
}

#[derive(Identifiable, Queryable, Associations)]
#[belongs_to(User, foreign_key="owner")]
#[belongs_to(User, foreign_key = "owner")]
pub struct Playlist {
id: i32,
owner: i32,
}

#[derive(Identifiable, Queryable, Associations)]
#[belongs_to(Playlist, foreign_key="playlist")]
#[belongs_to(Playlist, foreign_key = "playlist")]
pub struct PlaylistSong {
id: i32,
playlist: i32,
}

#[derive(Insertable)]
#[table_name="playlist_songs"]
#[table_name = "playlist_songs"]
pub struct NewPlaylistSong {
playlist: i32,
path: String,
ordering: i32,
}

pub fn list_playlists<T>(owner: &str, db: &T) -> Result<Vec<String>>
where T: ConnectionSource + VFSSource
where
T: ConnectionSource + VFSSource,
{
let connection = db.get_connection();

Expand All @@ -71,12 +72,9 @@ pub fn list_playlists<T>(owner: &str, db: &T) -> Result<Vec<String>>
}
}

pub fn save_playlist<T>(playlist_name: &str,
owner: &str,
content: &[String],
db: &T)
-> Result<()>
where T: ConnectionSource + VFSSource
pub fn save_playlist<T>(playlist_name: &str, owner: &str, content: &[String], db: &T) -> Result<()>
where
T: ConnectionSource + VFSSource,
{
let user: User;
let new_playlist: NewPlaylist;
Expand Down Expand Up @@ -119,14 +117,16 @@ pub fn save_playlist<T>(playlist_name: &str,

for (i, path) in content.iter().enumerate() {
let virtual_path = Path::new(&path);
if let Some(real_path) = vfs.virtual_to_real(virtual_path)
.ok()
.and_then(|p| p.to_str().map(|s| s.to_owned())) {
if let Some(real_path) = vfs
.virtual_to_real(virtual_path)
.ok()
.and_then(|p| p.to_str().map(|s| s.to_owned()))
{
new_songs.push(NewPlaylistSong {
playlist: playlist.id,
path: real_path,
ordering: i as i32,
});
playlist: playlist.id,
path: real_path,
ordering: i as i32,
});
}
}

Expand All @@ -151,7 +151,8 @@ pub fn save_playlist<T>(playlist_name: &str,
}

pub fn read_playlist<T>(playlist_name: &str, owner: &str, db: &T) -> Result<Vec<Song>>
where T: ConnectionSource + VFSSource
where
T: ConnectionSource + VFSSource,
{
let vfs = db.get_vfs()?;
let songs: Vec<Song>;
Expand Down Expand Up @@ -201,7 +202,8 @@ pub fn read_playlist<T>(playlist_name: &str, owner: &str, db: &T) -> Result<Vec<
}

pub fn delete_playlist<T>(playlist_name: &str, owner: &str, db: &T) -> Result<()>
where T: ConnectionSource + VFSSource
where
T: ConnectionSource + VFSSource,
{
let connection = db.get_connection();

Expand Down
5 changes: 1 addition & 4 deletions src/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ impl PartialFile {
Range: Into<PartialFileRange>,
{
let range = range.into();
PartialFile {
file,
range,
}
PartialFile { file, range }
}

pub fn from_path<P: AsRef<Path>, Range>(path: P, range: Range) -> Result<PartialFile, io::Error>
Expand Down

0 comments on commit 15a10f0

Please sign in to comment.