pub struct NumId<Tag, R: NumIdRepr = u64>(/* private fields */);id only.Expand description
Tipli raqamli identifikator (legacy tizimlar, BIGINT ustunlar).
JSON’da har doim integer, DB’da BIGINT.
R — ichki ko’rinish, NumIdRepr (u64 yoki i64); default u64, shuning uchun
NumId<Order> avvalgidek ishlaydi.
NumId<Tag> (u64) | NumId<Tag, i64> | |
|---|---|---|
| Diapazon | 0..=u64::MAX | i64::MIN..=i64::MAX |
Encode (BIGINT) | > i64::MAX → IdError::NumberTooLarge | hech qachon xato yo’q |
Decode (BIGINT) | manfiy → IdError::NumberNegative | hech qachon xato yo’q |
| Manfiy legacy ID | ❌ | ✅ |
DB bilan ishlaganda i64 ko’rinishi runtime xatolarining butun sinfini yo’q qiladi.
u64 kerak bo’lsa, chegarani input tomonida try_new_db_safe
yoki parse_db_safe bilan qo’ying — query paytida emas.
Implementations§
Source§impl<Tag, R: NumIdRepr> NumId<Tag, R>
impl<Tag, R: NumIdRepr> NumId<Tag, R>
Sourcepub fn parse(value: &str) -> Result<Self, IdError>
pub fn parse(value: &str) -> Result<Self, IdError>
Matndan. u64 ko’rinishida -/+ rad etiladi, i64 da - qabul qilinadi.
Sourcepub fn to_bigint(&self) -> Result<i64, IdError>
pub fn to_bigint(&self) -> Result<i64, IdError>
DB BIGINT (i64) qiymati — sqlx::Encode aynan shuni chaqiradi.
Query’ni yuborishdan oldin tekshirish uchun: i64 ko’rinishida har doim Ok.
Sourcepub fn is_db_safe(&self) -> bool
pub fn is_db_safe(&self) -> bool
BIGINT ustuniga sig’adimi (i64 ko’rinishida har doim true).
Source§impl<Tag> NumId<Tag, u64>
impl<Tag> NumId<Tag, u64>
Sourcepub const MAX_DB_SAFE: u64
pub const MAX_DB_SAFE: u64
BIGINT (i64) ustuniga sig’adigan eng katta qiymat.
Sourcepub const fn try_new_db_safe(value: u64) -> Result<Self, IdError>
pub const fn try_new_db_safe(value: u64) -> Result<Self, IdError>
new ning tekshiradigan varianti: > MAX_DB_SAFE → Err.
IdError::NumberTooLarge ni query paytidan konstruksiya paytiga ko’chiradi.
Trait Implementations§
impl<Tag, R: NumIdRepr> Copy for NumId<Tag, R>
Source§impl<'r, DB: Database, Tag, R: NumIdRepr> Decode<'r, DB> for NumId<Tag, R>
Available on crate features sqlx-0_8 or sqlx-0_9 only.
impl<'r, DB: Database, Tag, R: NumIdRepr> Decode<'r, DB> for NumId<Tag, R>
sqlx-0_8 or sqlx-0_9 only.Source§impl<'r, DB: Database, Tag, R: NumIdRepr> Decode<'r, DB> for NumId<Tag, R>
Available on crate features sqlx-0_8 or sqlx-0_9 only.
impl<'r, DB: Database, Tag, R: NumIdRepr> Decode<'r, DB> for NumId<Tag, R>
sqlx-0_8 or sqlx-0_9 only.Source§impl<'de, Tag, R: NumIdRepr> Deserialize<'de> for NumId<Tag, R>
Available on crate feature serde only.
impl<'de, Tag, R: NumIdRepr> Deserialize<'de> for NumId<Tag, R>
serde only.Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl<'q, DB: Database, Tag, R: NumIdRepr> Encode<'q, DB> for NumId<Tag, R>
Available on crate features sqlx-0_8 or sqlx-0_9 only.
impl<'q, DB: Database, Tag, R: NumIdRepr> Encode<'q, DB> for NumId<Tag, R>
sqlx-0_8 or sqlx-0_9 only.Source§fn encode_by_ref(
&self,
buf: &mut DB::ArgumentBuffer<'q>,
) -> Result<IsNull, BoxDynError>
fn encode_by_ref( &self, buf: &mut DB::ArgumentBuffer<'q>, ) -> Result<IsNull, BoxDynError>
Source§fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
self into buf in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
fn size_hint(&self) -> usize
Source§impl<'q, DB: Database, Tag, R: NumIdRepr> Encode<'q, DB> for NumId<Tag, R>
Available on crate features sqlx-0_8 or sqlx-0_9 only.
impl<'q, DB: Database, Tag, R: NumIdRepr> Encode<'q, DB> for NumId<Tag, R>
sqlx-0_8 or sqlx-0_9 only.Source§fn encode_by_ref(
&self,
buf: &mut DB::ArgumentBuffer,
) -> Result<IsNull, BoxDynError>
fn encode_by_ref( &self, buf: &mut DB::ArgumentBuffer, ) -> Result<IsNull, BoxDynError>
Source§fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
self into buf in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
fn size_hint(&self) -> usize
impl<Tag, R: NumIdRepr> Eq for NumId<Tag, R>
Source§impl<Tag, R: NumIdRepr> Ord for NumId<Tag, R>
impl<Tag, R: NumIdRepr> Ord for NumId<Tag, R>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<Tag, R: NumIdRepr> PartialOrd for NumId<Tag, R>
impl<Tag, R: NumIdRepr> PartialOrd for NumId<Tag, R>
Source§impl<Tag, R: NumIdRepr> PgHasArrayType for NumId<Tag, R>
Available on crate features sqlx-0_8 or sqlx-0_9 only.
impl<Tag, R: NumIdRepr> PgHasArrayType for NumId<Tag, R>
sqlx-0_8 or sqlx-0_9 only.fn array_type_info() -> PgTypeInfo
fn array_compatible(ty: &PgTypeInfo) -> bool
Source§impl<Tag, R: NumIdRepr> PgHasArrayType for NumId<Tag, R>
Available on crate features sqlx-0_8 or sqlx-0_9 only.
impl<Tag, R: NumIdRepr> PgHasArrayType for NumId<Tag, R>
sqlx-0_8 or sqlx-0_9 only.fn array_type_info() -> PgTypeInfo
fn array_compatible(ty: &PgTypeInfo) -> bool
Source§impl<Tag> TryFrom<NumId<Tag, i64>> for NumId<Tag, u64>
i64 → u64 ko’rinishiga o’tish: manfiy qiymatda IdError::NumberNegative.
impl<Tag> TryFrom<NumId<Tag, i64>> for NumId<Tag, u64>
i64 → u64 ko’rinishiga o’tish: manfiy qiymatda IdError::NumberNegative.
Source§impl<Tag> TryFrom<NumId<Tag>> for NumId<Tag, i64>
u64 → i64 ko’rinishiga o’tish: > i64::MAX da IdError::NumberTooLarge.
impl<Tag> TryFrom<NumId<Tag>> for NumId<Tag, i64>
u64 → i64 ko’rinishiga o’tish: > i64::MAX da IdError::NumberTooLarge.
Source§impl<Tag, R: NumIdRepr> TryFrom<String> for NumId<Tag, R>
String bu yerda qayta ishlatilmaydi — raqam parse qilinadi, matn
saqlanmaydi. string_newtype! dagi nol-allocation kafolati matn saqlaydigan
tiplarga tegishli; Id<Tag> da ham xuddi shunday.
impl<Tag, R: NumIdRepr> TryFrom<String> for NumId<Tag, R>
String bu yerda qayta ishlatilmaydi — raqam parse qilinadi, matn
saqlanmaydi. string_newtype! dagi nol-allocation kafolati matn saqlaydigan
tiplarga tegishli; Id<Tag> da ham xuddi shunday.
Source§impl<DB: Database, Tag, R: NumIdRepr> Type<DB> for NumId<Tag, R>
Available on crate features sqlx-0_8 or sqlx-0_9 only.
impl<DB: Database, Tag, R: NumIdRepr> Type<DB> for NumId<Tag, R>
sqlx-0_8 or sqlx-0_9 only.Auto Trait Implementations§
impl<Tag, R> Freeze for NumId<Tag, R>
impl<Tag, R> RefUnwindSafe for NumId<Tag, R>
impl<Tag, R> Send for NumId<Tag, R>
impl<Tag, R> Sync for NumId<Tag, R>
impl<Tag, R> Unpin for NumId<Tag, R>
impl<Tag, R> UnsafeUnpin for NumId<Tag, R>
impl<Tag, R> UnwindSafe for NumId<Tag, R>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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