pub struct RSync { /* private fields */ }Expand description
远程同步,用于计算数据的差异以及根据差异和旧数据构建出新的数据
§Examples
let oldStr = "qwertyuiopasdfghjklzxcvbnmrrrrrrrrrrrefregrtytfessfrer";
let newStr = "qzetyuioasdfgzjklzxcwbkmrerrrrrrrrrrrtghgtrrrrrfgsfrer";
let oldBytes = String::from(oldStr).into_bytes();
let newBytes = String::from(newStr).into_bytes();
let rsync = RSync::new(5);
let check_sums = rsync.check_sum(&oldBytes); // 根据旧数据,算出校验和
let diffs = rsync.diff(&newBytes, check_sums); // 根据旧数据的校验和、新数据,算出新数据与旧数据的差异
let r = rsync.sync(&oldBytes, diffs); // 根据旧数据和差异,还原为新的数据
let s = String::from_utf8(r).expect("-----------------------------");
assert_eq!(&s, newStr); Implementations§
Auto Trait Implementations§
impl Freeze for RSync
impl RefUnwindSafe for RSync
impl Send for RSync
impl Sync for RSync
impl Unpin for RSync
impl UnwindSafe for RSync
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more