Skip to content

Typos and formatting. #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/gtid_set.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Author Axel Viala <[email protected]>
// Done on free time inspired a lot by pymysqlreplication own implementation.
// Licence MIT + APACHE 2.
// Done on free time inspired a lot by pymysql replication own implementation.
// License MIT + APACHE 2.

use crate::{Gtid, GtidError};
use std::iter::Iterator;
Expand Down Expand Up @@ -43,7 +43,7 @@ impl From<&[Gtid]> for GtidSet {
impl GtidSet {
pub fn include_gtid(&mut self, gtid: &Gtid) {
match self.gtids.get_mut(&gtid.sid) {
// Unwraping is safe we work on the same sid
// Unwrapping is safe we work on the same sid
Some(g) => g.include_transactions(gtid).unwrap(),
None => {
self.gtids.insert(gtid.sid, gtid.clone());
Expand All @@ -53,7 +53,7 @@ impl GtidSet {

pub fn include_gtid_consume(&mut self, gtid: Gtid) {
match self.gtids.get_mut(&gtid.sid) {
// Unwraping is safe we work on the same sid
// Unwrapping is safe we work on the same sid
Some(g) => g.include_transactions(&gtid).unwrap(),
None => {
self.gtids.insert(gtid.sid, gtid);
Expand Down Expand Up @@ -91,7 +91,7 @@ impl GtidSet {
/// - `n_sid`: u64 is the number of Gtid to read
/// - `Gtid`: `n_sid` * `Gtid_encoded_size` times See [Gtid] documentation for details.
/// ```txt
/// Alligned on u64 bit
/// Aligned on u64 bit
/// +-+-+-+-+-+-+-+-+-+-+
/// | n_gtid u64 |
/// | |
Expand Down Expand Up @@ -139,7 +139,10 @@ impl GtidSet {

/// Iterator over raw values useful for bridging with `Sid` type in mysql crate.
pub fn into_raw(self) -> Vec<([u8; 16], Vec<(u64, u64)>)> {
self.gtids.into_values().map(|gtid| gtid.into_raw()).collect()
self.gtids
.into_values()
.map(|gtid| gtid.into_raw())
.collect()
}
}

Expand Down
20 changes: 10 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl Gtid {
String::from_utf8_lossy(&sid[..]).to_string()
}

/// Unsable may be removed.
/// Unstable may be removed.
pub fn raw_gtid_unchecked(sid: [u8; 36]) -> Result<Gtid, GtidError> {
let sid = parse_uuid(&sid)?;

Expand Down Expand Up @@ -115,7 +115,7 @@ impl Gtid {
}

if self.intervals.iter().any(|x| overlap(x, interval)) {
return Err(GtidError::OverlapingInterval);
return Err(GtidError::OverlappingInterval);
}

self.add_interval_unchecked(interval);
Expand Down Expand Up @@ -144,7 +144,7 @@ impl Gtid {

/// Remove an interval from intervals.
///
/// Does not check for Zero in internval, interval badly ordered or overlap.
/// Does not check for Zero in interval, interval badly ordered or overlap.
/// Assume interval is well formed.
pub fn sub_interval(&mut self, interval: &(u64, u64)) -> Result<(), GtidError> {
if interval.0 == 0 || interval.1 == 0 {
Expand Down Expand Up @@ -208,7 +208,7 @@ impl Gtid {
///
/// For binary format description see [Gtid::serialize]
///
/// Known issue: sid need to be validated and not accepted blindy.
/// Known issue: sid need to be validated and not accepted blindly.
pub fn parse<R: io::Read>(reader: &mut R) -> io::Result<Gtid> {
// Reading and decoding SID
let mut sid = [0u8; 16];
Expand Down Expand Up @@ -267,7 +267,7 @@ impl Gtid {
// Encode in little endian the len
writer.write_all(&(self.intervals.len() as u64).to_le_bytes())?;

// Encode the intervals itselfs in little endian (start, stop)
// Encode the intervals themselves in little endian (start, stop)
for (start, end) in self.intervals.iter() {
writer.write_all(&start.to_le_bytes())?;
writer.write_all(&end.to_le_bytes())?;
Expand Down Expand Up @@ -305,7 +305,7 @@ pub enum GtidError {
/// SID or Interval is in invalid form
ParseError,
/// Intervals overlaps
OverlapingInterval,
OverlappingInterval,
/// Interval must be Ordered (sorted)
IntervalBadlyOrdered,
/// Interval shall not contain 0
Expand All @@ -323,7 +323,7 @@ impl Display for GtidError {
}

/// Parse a human-generated interval, end value will be incremented to match mysql internals.
/// Exemple if given `1,2` will output `(1, 3)`.
/// Example if given `1,2` will output `(1, 3)`.
///
/// ```ignore
/// # use crate::parse_interval;
Expand Down Expand Up @@ -370,7 +370,7 @@ impl TryFrom<&str> for Gtid {
.windows(2)
.any(|tuples| overlap(&tuples[0], &tuples[1]))
{
return Err(GtidError::OverlapingInterval);
return Err(GtidError::OverlappingInterval);
}
Ok(Gtid { sid, intervals })
}
Expand Down Expand Up @@ -604,7 +604,7 @@ mod test {

assert_eq!(
gtid.add_interval(&(50, 51)),
Err(GtidError::OverlapingInterval)
Err(GtidError::OverlappingInterval)
);

assert_eq!(gtid.intervals, [(1, 57)]);
Expand Down Expand Up @@ -804,6 +804,6 @@ mod test {
assert_eq!(Gtid::try_from(gtids), Err(GtidError::IntervalBadlyOrdered));

let gtids = "57b70f4e-20d3-11e5-a393-4a63946f7eac:1-5:2-3";
assert_eq!(Gtid::try_from(gtids), Err(GtidError::OverlapingInterval));
assert_eq!(Gtid::try_from(gtids), Err(GtidError::OverlappingInterval));
}
}