pub struct Label(/* private fields */);Expand description
A CLASSIFICATION’S WORD — what a detector, a classifier or a tagger says a thing IS.
A Utf8Bytes underneath, and a different type for the reason every newtype in
primitives is one: it carries an INVARIANT its representation cannot
state. A label is a word somebody said, and nothing at all is not one — so new
is the only way in and it refuses the empty case.
§THE ENGINE OWNS NORMALISATION, AND THIS TYPE OWNS EXISTENCE
This type does not fold case, and it never will. The division is the producer’s, stated in
avanalyze’s own contract: the engine lowercases and trims image-classification labels but
passes animal labels through verbatim, and uses the literal "person" for human subjects — the
label vocabulary is Apple’s, not this crate’s. One producer therefore emits cat and Golden Retriever from the same run, deliberately, and a type that lowercased them both would be a type
overruling the engine about a vocabulary the engine owns.
So Cat and cat are TWO labels here. A caller that wants them to be one asks with
containsNocase or eqNocase’s neighbours on TextFilter, which is where a case question
belongs: a QUERY’s, asked per query, rather than a value’s, decided once for everybody at a
constructor.
§WHAT IS REFUSED, and it is one rule
A label that is empty, or that is nothing but whitespace. The second clause is the first one
read honestly: " " is a string a producer sent by accident, it names nothing, and admitting
it would put a row in a table whose label no query can ever match and no reader can ever see.
The whitespace is a PREDICATE and never a transform. Label::new(" cat ") succeeds and
holds " cat " — the six characters it was handed, byte for byte. That is the division above
kept where it would have been easiest to bend: trimming is normalisation, normalisation is the
engine’s, and this crate has no trim-at-a-constructor anywhere else either. What the trim decides
is whether there is a word here, not what the word is.
It follows that a value this crate wrote reads back byte for byte at every door — the decode, the
cursor and the document all re-enter new, and a constructor that rewrites nothing
admits exactly what it was given.
§NO VOCABULARY, and that is the ruling rather than an omission
A label is an OPEN word. Every model ships its own roster — Apple’s image classifier, a
zero-shot tagger, a barcode symbology reader — the rosters disagree, and none of them is a
standard this crate could hold a table of. So there is no enum here and none is coming: an
#[ingraph::enumerate] vocabulary over a model’s output would be a closed surface over an open
world, which is the one shape this framework does not build. See
lang, where the opposite case is argued — a language IS a standard,
so it IS a type family.
§Examples
use ingraph::Label;
assert_eq!(Label::new("golden retriever").unwrap().as_str(), "golden retriever");
// Case is the ENGINE's, so two spellings are two labels.
assert_ne!(Label::new("Cat").unwrap(), Label::new("cat").unwrap());
// The whitespace decides whether there is a word, and never what the word is.
assert!(Label::new("").is_err());
assert!(Label::new(" ").is_err());
assert_eq!(Label::new(" cat ").unwrap().as_str(), " cat ");Implementations§
Source§impl Label
impl Label
Sourcepub fn new(text: impl Into<Utf8Bytes>) -> Result<Self, EmptyLabel>
pub fn new(text: impl Into<Utf8Bytes>) -> Result<Self, EmptyLabel>
Construct a label, or refuse a value that is not one.
Takes anything the crate’s text carrier is built from — a &str, a String, a
Utf8Bytes already in hand — so a caller holding an owned word hands it over rather than
copying it, and Label::new(Utf8Bytes::from_static("person")) is the door a compile-time word
takes with no allocation at all.
§Errors
EmptyLabel where the text is empty or holds nothing but whitespace. It is the only refusal
this type has — see the type’s note, where the case question is answered.
Sourcepub fn into_inner(self) -> Utf8Bytes
pub fn into_inner(self) -> Utf8Bytes
The word, as the carrier it is held in.
Trait Implementations§
Source§impl<'a, R: Row> Assemble<'a, R> for Label
Available on crate feature sqlx only.AND THE WORD BACK IN, through the constructor rather than around it.
impl<'a, R: Row> Assemble<'a, R> for Label
sqlx only.AND THE WORD BACK IN, through the constructor rather than around it.
A database is exactly the place that can hand back a value this type says cannot exist — a
hand-written UPDATE, a restore, a column shared with something else — so the read refuses
rather than substituting a placeholder. That is Count’s posture at its own
column and every subtag’s at theirs: loudly, at the row that held it, never a value quietly
minted around the hole.
Source§impl<Db> Carrier<Db> for Label
Available on crate feature sqlx only.ONE BIND OUT — the word, as text.
impl<Db> Carrier<Db> for Label
sqlx only.ONE BIND OUT — the word, as text.
An OWNED String rather than the borrowed &str the slot already holds, and the reason is
sqlx::QueryBuilder’s own lifetime rather than a preference: push_bind requires its value to
outlive the builder’s 'args, which this trait’s signature leaves unrelated to &self, so a
borrow of self cannot satisfy it. That is the same copy every text newtype in
primitives pays at this seat.
Source§fn push_bind(&self, qb: &mut QueryBuilder<Db>)
fn push_bind(&self, qb: &mut QueryBuilder<Db>)
qb. Read moreSource§fn push_value_bind(&self, qb: &mut QueryBuilder<Db>)
fn push_value_bind(&self, qb: &mut QueryBuilder<Db>)
Source§impl ColumnKind for Label
ONE column, which is the default — stated rather than inherited, because the two composites
in this house read their own widths off this row and a reader auditing them should find the
answer here rather than the absence of one.
impl ColumnKind for Label
ONE column, which is the default — stated rather than inherited, because the two composites in this house read their own widths off this row and a reader auditing them should find the answer here rather than the absence of one.
Source§const SEGMENTS: &'static [ColumnShape] = _
const SEGMENTS: &'static [ColumnShape] = _
Source§const ORDER: &'static [OrderLevel] = _
const ORDER: &'static [OrderLevel] = _
Source§impl CursorValue for Label
THE KEYSET POSITION: the word’s UTF-8 bytes, which is byte for byte what Utf8Bytes’ own
row writes — so a label column and a text column page past the same cursor.
impl CursorValue for Label
THE KEYSET POSITION: the word’s UTF-8 bytes, which is byte for byte what Utf8Bytes’ own
row writes — so a label column and a text column page past the same cursor.
No framing is added, and none may be: a cursor slot is already length-delimited by the layer above, so a row for a variable-width value writes the value and nothing else. The read RE-VALIDATES because a cursor is a string a CLIENT hands back — a forged empty position is refused rather than turned into a label whose type says it cannot exist.
Source§impl Debug for Label
The word QUOTED, under the type’s own name — which is what makes a whitespace-carrying label
visible in a test failure instead of vanishing into the alignment.
impl Debug for Label
The word QUOTED, under the type’s own name — which is what makes a whitespace-carrying label visible in a test failure instead of vanishing into the alignment.
Source§impl DefaultMarker for Label
The interpretation a Label field is read under — the TEXT family’s, which is what puts
Option<Label> on the isNull road rather than on a collection’s.
impl DefaultMarker for Label
The interpretation a Label field is read under — the TEXT family’s, which is what puts
Option<Label> on the isNull road rather than on a collection’s.
Source§type Marker = StringMarker<Label>
type Marker = StringMarker<Label>
impl Eq for Label
ONE direction, which is the type’s whole subject: From<Utf8Bytes> for Label would say that any
text IS a label, and the empty string is the counter-example this newtype exists to keep out of a
row. Minting one is Label::new, where the caller meets the refusal.
Source§impl From<Label> for String
What gives String: TryFrom<Label> through std’s blanket, which is the crossing a TEXT
column’s comparison makes — and it makes it with Error = Infallible, a label being valid text
by construction.
impl From<Label> for String
What gives String: TryFrom<Label> through std’s blanket, which is the crossing a TEXT
column’s comparison makes — and it makes it with Error = Infallible, a label being valid text
by construction.
Source§impl MongoCarrier for Label
Available on crate feature mongo only.THE DOCUMENT’S FORM: a BSON String — the same text the TEXT column above binds, at the
one BSON type that holds it.
impl MongoCarrier for Label
mongo only.THE DOCUMENT’S FORM: a BSON String — the same text the TEXT column above binds, at the
one BSON type that holds it.
A label is ONE WORD, so there is nothing here of a composite’s key-set question. This row is the
FILTER OPERAND’s form and not a serde row, which is the posture every storage type this crate
ships takes — see Timestamp’s, where the E0277 a bare column earns at a
declaration is named.
Source§impl MongoExtract for Label
Available on crate feature mongo only.THE READ: the same word, back through the door — MongoCarrier’s
mirror.
impl MongoExtract for Label
mongo only.THE READ: the same word, back through the door — MongoCarrier’s
mirror.
A string field is exactly as untrusted as the TEXT column Assemble above
reads: nothing stops a document holding "", one written before this type existed, or one
written by hand for a test. So the read goes through Label::new rather than wrapping the
bytes.
Source§impl Ord for Label
impl Ord for Label
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 PartialOrd for Label
impl PartialOrd for Label
Source§impl<Db> StoredAs<Db> for Label
THE STORED WORD is text’s, in every dialect that has one.
impl<Db> StoredAs<Db> for Label
THE STORED WORD is text’s, in every dialect that has one.
Delegated to String rather than named, for the reason the bind below is: a label IS its text,
so the column is a text column and the dialect’s own word for one is the only answer. The
delegation carries the ADMISSION with it — a label is declarable exactly where text is, which is
everywhere.
The non-emptiness is kept by the DECODE rather than by the schema; no dialect here has a CHECK
this crate emits. See the assemble row below, which refuses.
Source§impl StringFilterMarker for Label
The TEXT reading, which is what an open vocabulary earns.
impl StringFilterMarker for Label
The TEXT reading, which is what an open vocabulary earns.
A label takes the twenty-slot TextFilter rather than the eight-slot
ScalarFilter the lang subtags take, and the
difference is what the two words ARE. A subtag is one token of a closed grammar, so does it
start with is a question about spelling rather than about meaning. A label is FREE TEXT from a
model’s own roster — golden retriever, traffic light, person — so contains: "retriever"
is a real question a real client asks, and the nocase half of every affix slot is where the
case this type refuses to fold gets asked about instead.
The lexical ORDERING slots come with the kind and they are honest here: text has a byte order,
Utf8Bytes publishes a filter carrying gt/gte/lt/lte over exactly that order, and the
non-emptiness rule disturbs none of it. A label column is an ORDER SUBJECT in the same breath —
see the CursorValue row above, which is what a page walks.
impl StructuralPartialEq for Label
Source§impl TextWire<Label> for LabelWire
impl TextWire<Label> for LabelWire
Source§const NAME: &'static str = "LabelFilter"
const NAME: &'static str = "LabelFilter"
T under this reading is published as.Source§type Error = EmptyLabel
type Error = EmptyLabel
Infallible where a crossing cannot refuse.Source§impl ToGraphqlInput for Label
Available on crate feature async-graphql only.THE CROSSING IN — a label arrives as the roster’s own String, and the non-emptiness is kept
HERE.
impl ToGraphqlInput for Label
async-graphql only.THE CROSSING IN — a label arrives as the roster’s own String, and the non-emptiness is kept
HERE.
No #[Scalar] of its own, and the absence is NormCoord’s ruling one house
over rather than an omission: a named scalar has to say something the roster does not, and what a
Label scalar would have said is NON-EMPTY — a constructor’s promise rather than a grammar,
which a client can act on nowhere. So a label column and a plain text column publish one SDL
scalar, the rule reaches a reader through the FIELD’s documentation, and every operand reaches it
through Label::new, which this row calls.
Source§type Error = EmptyLabel
type Error = EmptyLabel
Infallible where a crossing cannot refuse.Source§impl ToGraphqlOutput for Label
Available on crate feature async-graphql only.AND OUT, mirroring the row above so the two directions cannot come to disagree.
impl ToGraphqlOutput for Label
async-graphql only.AND OUT, mirroring the row above so the two directions cannot come to disagree.
A BORROW of the text rather than of the value, which is Utf8Bytes’ own bargain at this seat:
the label has no scalar to be returned as, so what a field yields is the string it holds.
Auto Trait Implementations§
impl !Freeze for Label
impl RefUnwindSafe for Label
impl Send for Label
impl Sync for Label
impl Unpin for Label
impl UnsafeUnpin for Label
impl UnwindSafe for Label
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
Source§impl<Db, T> DialectCursor<Db> for Twhere
T: CursorValue,
impl<Db, T> DialectCursor<Db> for Twhere
T: CursorValue,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.impl<T> Fruit for 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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<K> PositionKey for K
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> RootKey for T
Source§impl<T> Searchable for T
impl<T> Searchable for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.Source§impl<T> WireScore for Twhere
T: ToGraphqlOutput + Send + Sync + 'static,
<T as ToGraphqlOutput>::Output<'a>: for<'a> OutputType,
impl<T> WireScore for Twhere
T: ToGraphqlOutput + Send + Sync + 'static,
<T as ToGraphqlOutput>::Output<'a>: for<'a> OutputType,
Source§type Wire<'a> = <T as ToGraphqlOutput>::Output<'a>
where
T: 'a
type Wire<'a> = <T as ToGraphqlOutput>::Output<'a> where T: 'a
async-graphql only.OutputType — the BACKEND’s demand, made where the
backend spends the form.Source§fn wire_score(&self) -> <T as WireScore>::Wire<'_>
fn wire_score(&self) -> <T as WireScore>::Wire<'_>
async-graphql only.