pub fn grab_posts_by_tags(&mut self, groups: &[Group]) {
        for group in groups {
            for tag in &group.tags {
                match tag.tag_type {
                    TagType::Pool => {
                        let mut entry: PoolEntry = self
                            .request_sender
                            .get_entry_from_appended_id(&tag.name, "pool");
                        let name = &entry.name;
                        let mut posts = self.special_search(&format!("pool:{}", entry.id));

                        // Updates entry post ids in case any posts were filtered in the search.
                        entry
                            .post_ids
                            .retain(|id| posts.iter().any(|post| post.id == *id));

                        // Sorts the pool to the original order given by entry.
                        for (i, id) in entry.post_ids.iter().enumerate() {
                            if posts[i].id != *id {
                                let correct_index = posts.iter().position(|e| e.id == *id).unwrap();
                                posts.swap(i, correct_index);
                            }
                        }

                        self.posts.push(PostCollection::new(
                            name,
                            "Pools",
                            GrabbedPost::entry_to_pool_vec(posts, name),
                        ));

                        info!(
                            "{} grabbed!",
                            console::style(format!("\"{}\"", name))
                                .color256(39)
                                .italic()
                        );
                    }
                    TagType::Set => {
                        let entry: SetEntry = self
                            .request_sender
                            .get_entry_from_appended_id(&tag.name, "set");
                        // Grabs posts from IDs in the set entry.
                        let posts = self.special_search(&format!("set:{}", entry.shortname));
                        self.posts.push(PostCollection::from_set(
                            &entry,
                            GrabbedPost::entry_to_vec(posts),
                        ));

                        info!(
                            "{} grabbed!",
                            console::style(format!("\"{}\"", entry.name))
                                .color256(39)
                                .italic()
                        );
                    }
                    TagType::Post => {
                        let entry: PostEntry = self
                            .request_sender
                            .get_entry_from_appended_id(&tag.name, "single");
                        let id = entry.id;
                        self.posts
                            .first_mut()
                            .unwrap()
                            .posts
                            .push(GrabbedPost::from(entry));

                        info!(
                            "Post with ID {} grabbed!",
                            console::style(format!("\"{}\"", id)).color256(39).italic()
                        );
                    }
                    TagType::General | TagType::Artist => {
                        let posts = self.get_posts_from_tag(tag);
                        self.posts.push(PostCollection::new(
                            &tag.name,
                            "General Searches",
                            GrabbedPost::entry_to_vec(posts),
                        ));
                        info!(
                            "{} grabbed!",
                            console::style(format!("\"{}\"", tag.name))
                                .color256(39)
                                .italic()
                        );
                    }
                    TagType::None => unreachable!(),
                };
            }
        }
    }
/// Iterates through tags and perform searches for each, grabbing them and storing them for later download.
Iterates through tags and perform searches for each, grabbing them and storing them for later download.
Iterates through tags and perform searches for each grabbing them and storing them for later download .
pub fn grab_posts_by_tags(&mut self, groups: &[Group]) {
        for group in groups {
            for tag in &group.tags {
                match tag.tag_type {
                    TagType::Pool => {
                        let mut entry: PoolEntry = self
                            .request_sender
                            .get_entry_from_appended_id(&tag.name, "pool");
                        let name = &entry.name;
                        let mut posts = self.special_search(&format!("pool:{}", entry.id));
                        // Updates entry post ids in case any posts were filtered in the search.
                        entry
                            .post_ids
                            .retain(|id| posts.iter().any(|post| post.id == *id));
                        // Sorts the pool to the original order given by entry.
                        for (i, id) in entry.post_ids.iter().enumerate() {
                            if posts[i].id != *id {
                                let correct_index = posts.iter().position(|e| e.id == *id).unwrap();
                                posts.swap(i, correct_index);
                            }
                        }
                        self.posts.push(PostCollection::new(
                            name,
                            "Pools",
                            GrabbedPost::entry_to_pool_vec(posts, name),
                        ));
                        info!(
                            "{} grabbed!",
                            console::style(format!("\"{}\"", name))
                                .color256(39)
                                .italic()
                        );
                    }
                    TagType::Set => {
                        let entry: SetEntry = self
                            .request_sender
                            .get_entry_from_appended_id(&tag.name, "set");
                        // Grabs posts from IDs in the set entry.
                        let posts = self.special_search(&format!("set:{}", entry.shortname));
                        self.posts.push(PostCollection::from_set(
                            &entry,
                            GrabbedPost::entry_to_vec(posts),
                        ));
                        info!(
                            "{} grabbed!",
                            console::style(format!("\"{}\"", entry.name))
                                .color256(39)
                                .italic()
                        );
                    }
                    TagType::Post => {
                        let entry: PostEntry = self
                            .request_sender
                            .get_entry_from_appended_id(&tag.name, "single");
                        let id = entry.id;
                        self.posts
                            .first_mut()
                            .unwrap()
                            .posts
                            .push(GrabbedPost::from(entry));
                        info!(
                            "Post with ID {} grabbed!",
                            console::style(format!("\"{}\"", id)).color256(39).italic()
                        );
                    }
                    TagType::General | TagType::Artist => {
                        let posts = self.get_posts_from_tag(tag);
                        self.posts.push(PostCollection::new(
                            &tag.name,
                            "General Searches",
                            GrabbedPost::entry_to_vec(posts),
                        ));
                        info!(
                            "{} grabbed!",
                            console::style(format!("\"{}\"", tag.name))
                                .color256(39)
                                .italic()
                        );
                    }
                    TagType::None => unreachable!(),
                };
            }
        }
    }
pub fn grab_posts_by_tags ( & mut self , groups : & [ Group ] ) { for group in groups { for tag in & group . tags { match tag . tag_type { TagType :: Pool => { let mut entry : PoolEntry = self . request_sender . get_entry_from_appended_id ( & tag . name , " " ) ; let name = & entry . name ; let mut posts = self . special_search ( & format ! ( " " entry id ) ) ; // Updates entry post ids in case any posts were filtered in the search. entry . post_ids . retain ( | id | posts . iter ( ) . any ( | post | post . id == * id ) ) ; // Sorts the pool to the original order given by entry. for ( i , id ) in entry . post_ids . iter ( ) . enumerate ( ) { if posts [ i ] . id != * id { let correct_index = posts . iter ( ) . position ( | e | e . id == * id ) . unwrap ( ) ; posts . swap ( i , correct_index ) ; } } self . posts . push ( PostCollection :: new ( name , " " , GrabbedPost :: entry_to_pool_vec ( posts , name ) , ) ) ; info ! ( " " console style ( format ( " \" \" " name ) ) color256 ( 39 ) italic ( ) ) ; } TagType :: Set => { let entry : SetEntry = self . request_sender . get_entry_from_appended_id ( & tag . name , " " ) ; // Grabs posts from IDs in the set entry. let posts = self . special_search ( & format ! ( " " entry shortname ) ) ; self . posts . push ( PostCollection :: from_set ( & entry , GrabbedPost :: entry_to_vec ( posts ) , ) ) ; info ! ( " " console style ( format ( " \" \" " entry name ) ) color256 ( 39 ) italic ( ) ) ; } TagType :: Post => { let entry : PostEntry = self . request_sender . get_entry_from_appended_id ( & tag . name , " " ) ; let id = entry . id ; self . posts . first_mut ( ) . unwrap ( ) . posts . push ( GrabbedPost :: from ( entry ) ) ; info ! ( " " console style ( format ( " \" \" " id ) ) color256 ( 39 ) italic ( ) ) ; } TagType :: General | TagType :: Artist => { let posts = self . get_posts_from_tag ( tag ) ; self . posts . push ( PostCollection :: new ( & tag . name , " " , GrabbedPost :: entry_to_vec ( posts ) , ) ) ; info ! ( " " console style ( format ( " \" \" " tag name ) ) color256 ( 39 ) italic ( ) ) ; } TagType :: None => unreachable ! ( ) , } ; } } }
Iterates through tags and perform searches for each, grabbing them and storing them for later download.
Iterates through tags and perform searches for each grabbing them and storing them for later download .
&mut self
groups
&[Group]
&mut self
groups
&[Group]