pub struct SlugOptions { /* private fields */ }Expand description
How slugs are built: separator, length, suffix numbering and transliteration.
use sea_orm_sluggable::SlugOptions;
let options = SlugOptions::default().separator("_").max_length(100);Implementations§
Source§impl SlugOptions
impl SlugOptions
Sourcepub fn separator(self, separator: &str) -> Self
pub fn separator(self, separator: &str) -> Self
Joins words and the uniqueness suffix. Default: -.
Sourcepub const fn max_length(self, max_length: usize) -> Self
pub const fn max_length(self, max_length: usize) -> Self
Cuts the slug before a uniqueness suffix is added, so the final value can be a few characters longer. Default: 250.
Sourcepub const fn suffix_start(self, suffix_start: u32) -> Self
pub const fn suffix_start(self, suffix_start: u32) -> Self
First number used when a slug is taken: title-1 by default,
title-2 with suffix_start(2).
Sourcepub const fn suffix_on_first(self, suffix_on_first: bool) -> Self
pub const fn suffix_on_first(self, suffix_on_first: bool) -> Self
Adds a suffix even to the first slug: title-1, title-2, …
instead of title, title-1, … Default: off.
Sourcepub fn suffix_with(
self,
suffix: impl Fn(&str, u32) -> String + Send + Sync + 'static,
) -> Self
pub fn suffix_with( self, suffix: impl Fn(&str, u32) -> String + Send + Sync + 'static, ) -> Self
Replaces the numeric suffix. Gets the base slug and the attempt number
(starting at suffix_start) and returns the part
that goes after the separator. It must eventually return something new,
or the uniqueness search never ends.
use sea_orm_sluggable::SlugOptions;
// title-v1, title-v2, ...
let options = SlugOptions::default().suffix_with(|_slug, attempt| format!("v{attempt}"));Sourcepub fn reserved<I, S>(self, words: I) -> Self
pub fn reserved<I, S>(self, words: I) -> Self
Slugs that must never be used, typically words your routes already
take: with reserved(["new"]) a post titled “New” gets new-1, so it
cannot shadow /posts/new. Compared case-insensitively. Default: none.
use sea_orm_sluggable::SlugOptions;
let options = SlugOptions::default().reserved(["new", "edit", "feed"]);Sourcepub fn transliterator(
self,
transliterator: impl Transliterator + 'static,
) -> Self
pub fn transliterator( self, transliterator: impl Transliterator + 'static, ) -> Self
Replaces the default AnyAscii transliteration.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SlugOptions
impl !UnwindSafe for SlugOptions
impl Forget for SlugOptions
impl Freeze for SlugOptionswhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const dyn Fn(&str, u32) -> String + Send + Sync is !null: Freeze,
PhantomData<dyn Fn(&str, u32) -> String + Send + Sync>: Freeze,
PhantomData<String>: Freeze,
*const dyn Transliterator is !null: Freeze,
PhantomData<dyn Transliterator>: Freeze,
impl Move for SlugOptions
impl Send for SlugOptions
impl Sync for SlugOptions
impl Unpin for SlugOptions
impl UnsafeUnpin for SlugOptionswhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const dyn Fn(&str, u32) -> String + Send + Sync is !null: UnsafeUnpin,
PhantomData<dyn Fn(&str, u32) -> String + Send + Sync>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
*const dyn Transliterator is !null: UnsafeUnpin,
PhantomData<dyn Transliterator>: UnsafeUnpin,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more