Added documentation

[?]
8LW8624xwrzheYNE1i3XKqUsNUezeTo6cRFa6qrKJout
Oct 11, 2021, 9:50 AM
RXIJUOA6ZV5WLAXOEMPFCOGYCCJSN5N76TFCMPVHRHC4S4G2CFHAC

Dependencies

Change contents

  • edit in src/lib.rs at line 1
    [3.47]
    [2.0]
    #![warn(missing_docs)]
    //! # Emote Mapper
    //!
    //! `emote_mapper` is a collection of utilities to create and use emote maps from [`twitchmote`](https://github.com/ModProg/twitchmote)
  • edit in src/lib.rs at line 20
    [3.167][3.167:244](),[3.244][2.49:50]()
    use serde::*;
    use serde_with::{serde_as, TryFromInto};
    use thiserror::Error;
  • replacement in src/lib.rs at line 24
    [2.136][3.244:245](),[3.244][3.244:245]()
    [2.136]
    [3.245]
    use serde::*;
    use serde_with::{serde_as, TryFromInto};
    use thiserror::Error;
  • edit in src/lib.rs at line 29
    [3.271]
    [3.271]
    /// The EmoteMapper holds a Map of emote names and code points
    /// It can be used for:
    /// - using an emote map stored as csv to map emotes
    /// - storing an emote map as csv
  • replacement in src/lib.rs at line 39
    [3.391][3.391:514]()
    fn default() -> Self {
    Self {
    map: Default::default(),
    emote_width: 3,
    }
    }
    [3.391]
    [3.514]
    fn default() -> Self { Self { map: Default::default(), emote_width: 3 } }
  • edit in src/lib.rs at line 43
    [3.536]
    [3.536]
    /// The emote width used for `to_string` and `replace_all`
    ///
    /// **NOTE:** This depends both on the emote and the primary font used by the terminal
  • replacement in src/lib.rs at line 51
    [3.659][3.659:785]()
    pub fn to_char(&self, emote_name: &str) -> Option<char> {
    self.map.get(emote_name).copied().map(char::from)
    }
    [3.659]
    [3.785]
    /// Returns the char representing the `emote_name`
    pub fn to_char(&self, emote_name: &str) -> Option<char> { self.map.get(emote_name).copied().map(char::from) }
  • edit in src/lib.rs at line 54
    [3.786]
    [3.786]
    /// Returns a string with the char representing the `emote_name` padded to `emte_width`
  • replacement in src/lib.rs at line 56
    [3.852][3.852:960]()
    self.to_char(emote_name)
    .map(|c| format!("{}{}", c, " ".repeat(self.emote_width - 1)))
    [3.852]
    [3.960]
    self.to_char(emote_name).map(|c| format!("{}{}", c, " ".repeat(self.emote_width - 1)))
  • edit in src/lib.rs at line 59
    [2.138]
    [2.138]
    /// Replaces all emotes in the `message` given
  • replacement in src/lib.rs at line 67
    [2.390][2.390:519]()
    self.to_string(w.get(0).unwrap().as_str())
    .unwrap_or_else(|| w.get(0).unwrap().as_str().to_owned())
    [2.390]
    [2.519]
    self.to_string(w.get(0).unwrap().as_str()).unwrap_or_else(|| w.get(0).unwrap().as_str().to_owned())
  • edit in src/lib.rs at line 74
    [3.1000]
    [3.1000]
    /// Creates an EmoteMapper from a Reader containing csv data
  • replacement in src/lib.rs at line 76
    [3.1075][3.1075:1215]()
    let mut rdr = csv::ReaderBuilder::new()
    .has_headers(false)
    .trim(Trim::All)
    .from_reader(rdr);
    [3.1075]
    [3.1215]
    let mut rdr = csv::ReaderBuilder::new().has_headers(false).trim(Trim::All).from_reader(rdr);
  • replacement in src/lib.rs at line 85
    [3.1478][3.1478:1568]()
    Ok(EmoteMapper {
    map,
    ..EmoteMapper::default()
    })
    [3.1478]
    [3.1568]
    Ok(EmoteMapper { map, ..EmoteMapper::default() })
  • replacement in src/lib.rs at line 87
    [3.1574][3.1574:1706]()
    pub fn from_path(p: &Path) -> Result<Self, EmoteMapperError> {
    Self::from_reader(File::open(p).map_err(IOError)?)
    }
    [3.1574]
    [3.1706]
    /// Creates an EmoteMapper from a File containing csv data
    pub fn from_path(p: &Path) -> Result<Self, EmoteMapperError> { Self::from_reader(File::open(p).map_err(IOError)?) }
  • replacement in src/lib.rs at line 95
    [3.1774][3.1774:1874]()
    fn from_str(s: &str) -> Result<Self, Self::Err> {
    Self::from_reader(s.as_bytes())
    }
    [3.1774]
    [3.1874]
    /// Creates an EmoteMapper from a String containing csv data
    fn from_str(s: &str) -> Result<Self, Self::Err> { Self::from_reader(s.as_bytes()) }
  • edit in src/lib.rs at line 101
    [3.1907]
    [3.1907]
    /// Writes the EmoteMapper as csv to a Writer
  • replacement in src/lib.rs at line 103
    [3.1985][3.1985:2096]()
    let mut wtr = csv::WriterBuilder::new()
    .has_headers(false)
    .from_writer(wtr);
    [3.1985]
    [3.2096]
    let mut wtr = csv::WriterBuilder::new().has_headers(false).from_writer(wtr);
  • edit in src/lib.rs at line 108
    [3.2253][3.2253:2384]()
    }
    pub fn to_path(self, p: &Path) -> Result<(), EmoteMapperError> {
    self.to_writer(File::open(p).map_err(IOError)?)
  • edit in src/lib.rs at line 109
    [3.2390]
    [3.2390]
    /// Stores the EmoteMapper as csv in a File
    pub fn to_path(self, p: &Path) -> Result<(), EmoteMapperError> { self.to_writer(File::open(p).map_err(IOError)?) }
  • edit in src/lib.rs at line 115
    [3.2429]
    [3.2429]
    /// The EmoteMapper as CSV
  • replacement in src/lib.rs at line 119
    [3.2515][3.2515:2630]()
    val.to_writer(unsafe { s.as_mut_vec() })
    .expect("Writing to String should not fail");
    [3.2515]
    [3.2630]
    val.to_writer(unsafe { s.as_mut_vec() }).expect("Writing to String should not fail");
  • replacement in src/lib.rs at line 142
    [3.3086][3.3086:3192]()
    fn from((name, code_point): (String, CodePoint)) -> Self {
    Mapping { name, code_point }
    }
    [3.3086]
    [3.3192]
    fn from((name, code_point): (String, CodePoint)) -> Self { Mapping { name, code_point } }
  • edit in src/lib.rs at line 146
    [3.3219]
    [3.3219]
    #[allow(missing_docs)]
  • replacement in src/lib.rs at line 160
    [3.3595][3.3595:3651]()
    fn from(cp: CodePoint) -> Self {
    cp.0
    }
    [3.3595]
    [3.3651]
    fn from(cp: CodePoint) -> Self { cp.0 }
  • replacement in src/lib.rs at line 164
    [3.3683][3.3683:3796]()
    fn fmt(&self, f: &mut __private::Formatter<'_>) -> std::fmt::Result {
    char::from(*self).fmt(f)
    }
    [3.3683]
    [3.3796]
    fn fmt(&self, f: &mut __private::Formatter<'_>) -> std::fmt::Result { char::from(*self).fmt(f) }
  • replacement in src/lib.rs at line 168
    [3.3833][3.3833:3915]()
    fn from(val: CodePoint) -> Self {
    format!("{:X}", val.0 as u32)
    }
    [3.3833]
    [3.3915]
    fn from(val: CodePoint) -> Self { format!("{:X}", val.0 as u32) }
  • replacement in src/lib.rs at line 176
    [3.4071][3.4071:4266]()
    char::from_u32(
    u32::from_str_radix(&s, 16).map_err(|_| InvalidCodepoint(s.to_string()))?,
    )
    .ok_or_else(|| InvalidCodepoint(s.to_string()))?,
    [3.4071]
    [3.4266]
    char::from_u32(u32::from_str_radix(&s, 16).map_err(|_| InvalidCodepoint(s.to_string()))?)
    .ok_or_else(|| InvalidCodepoint(s.to_string()))?,
  • replacement in examples/twitchchat.rs at line 6
    [3.159][2.537:662]()
    let em = EmoteMapper::from_path(&PathBuf::from("examples/twitch_emotes.csv"))
    .unwrap()
    .emote_width(2);
    [3.159]
    [3.359]
    let em = EmoteMapper::from_path(&PathBuf::from("examples/twitch_emotes.csv")).unwrap().emote_width(2);
  • replacement in examples/twitchchat.rs at line 8
    [3.360][2.663:786]()
    let messages = vec![
    "modproHi, how are you doing?",
    "<3, great",
    "tggleBoss Kappa xD",
    ];
    [3.360]
    [3.410]
    let messages = vec!["modproHi, how are you doing?", "<3, great", "tggleBoss Kappa xD"];