pub struct IdSwitcher { /* private fields */ }Implementations§
Source§impl IdSwitcher
impl IdSwitcher
Sourcepub fn new<S: AsRef<str>>(source: S, target: S) -> Self
pub fn new<S: AsRef<str>>(source: S, target: S) -> Self
Create a new IdSwitcher.
It can be used to switch the ids from a source base to a target base.
use light_id::IdSwitcher;
let switcher = IdSwitcher::new("0123456789", "abcdefghij");Sourcepub fn clone(&self) -> Self
pub fn clone(&self) -> Self
Returns a copy of the IdSwitcher.
use light_id::IdSwitcher;
let switcher = IdSwitcher::new("0123456789", "abcdefghij");
let switcher_2 = switcher.clone();Sourcepub fn min_target(&mut self, n: usize) -> &mut Self
pub fn min_target(&mut self, n: usize) -> &mut Self
Sets the min length of the converted ids.
use light_id::IdSwitcher;
let mut switcher = IdSwitcher::new("0123456789", "abcdefghij");
switcher.min_target(10);
assert_eq!("aaaaaaaaaa", switcher.switch("0"));Sourcepub fn min_source(&mut self, n: usize) -> &mut Self
pub fn min_source(&mut self, n: usize) -> &mut Self
Sets the min length of the source ids.
use light_id::IdSwitcher;
let mut switcher = IdSwitcher::new("0123456789", "abcdefghij");
switcher.min_source(10);
assert_eq!("0000000000", switcher.switch_reverse("a"));Sourcepub fn switch_count(&self, id: usize) -> String
pub fn switch_count(&self, id: usize) -> String
Switches an id count from the source base to the target base.
use light_id::IdSwitcher;
let switcher = IdSwitcher::new("0123456789", "abcdefghij");
assert_eq!("a", switcher.switch_count(0));Sourcepub fn switch<S: AsRef<str>>(&self, id: S) -> String
pub fn switch<S: AsRef<str>>(&self, id: S) -> String
Switches an id from the source base to the target base.
use light_id::IdSwitcher;
let switcher = IdSwitcher::new("0123456789", "abcdefghij");
assert_eq!("a", switcher.switch("0"));Sourcepub fn switch_count_reverse(&self, id: usize) -> String
pub fn switch_count_reverse(&self, id: usize) -> String
Switches an id count from the target base to the source base.
use light_id::IdSwitcher;
let switcher = IdSwitcher::new("0123456789", "abcdefghij");
assert_eq!("0", switcher.switch_count_reverse(0));Sourcepub fn switch_reverse<S: AsRef<str>>(&self, id: S) -> String
pub fn switch_reverse<S: AsRef<str>>(&self, id: S) -> String
Switches an id from the target base to the source base.
use light_id::IdSwitcher;
let switcher = IdSwitcher::new("0123456789", "abcdefghij");
assert_eq!("0", switcher.switch_reverse("a"));Auto Trait Implementations§
impl Freeze for IdSwitcher
impl RefUnwindSafe for IdSwitcher
impl Send for IdSwitcher
impl Sync for IdSwitcher
impl Unpin for IdSwitcher
impl UnsafeUnpin for IdSwitcher
impl UnwindSafe for IdSwitcher
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