mirror of
https://github.com/qdrant/qdrant.git
synced 2026-07-27 13:11:06 -05:00
* Refactor `PyUpdateOperation` constructors * Add default parameters to `PyVectorDataConfig::new` * Add `Repr` trait and `WriteExt` helper * Implement `__repr__` for config types * fixup! Implement `__repr__` for config types Use `Copy` instead of `Clone` * fixup! Implement `__repr__` for config types Add basic test * Implement `__repr__` for `PyPointId` * Implement `__repr__` for `PyVector` * Implement `__repr__` for `PyVectorInternal` * Implement `__repr__` for `PyPayload` * Implement `__repr__` for `PyValue` * Implement `__repr__` for `PyPoint` * Implement `__repr__` for `PyPointVectors` * Implement `__repr__` for `PyRecord` * Move `PyScoredPoint` into a separate file * Implement `__repr__` for `PyScoredPoint` * Cleanup examples * fixup! Implement `__repr__` for `PyScoredPoint` * Move `PyOrderValue` into separate file * Add `PyScoredPoint::order_value` * Implement `pyclass_repr` proc-macro attribute * Implement `__repr__` for config types using `pyclass_repr` attribute * Implement `__repr__` for `PySparseVector` using `pyclass_repr` attribute * Implement `__repr__` for `PyPoint` using `pyclass_repr` attribute * Implement `__repr__` for `PyPointVectors` using `pyclass_repr` attribute * Implement `__repr__` for `PyRecord` using `pyclass_repr` attribute * Implement `__repr__` for `PyScoredPoint` using `pyclass_repr` attribute * Minor fixes and cleanups * fixup! Minor fixes and cleanups * rollback copy for quantization config * rollback copy for quantization config --------- Co-authored-by: generall <andrey@vasnetsov.com>
35 lines
906 B
Rust
35 lines
906 B
Rust
pub fn pyclass_repr(input: proc_macro2::TokenStream) -> syn::Result<proc_macro2::TokenStream> {
|
|
let impl_block: syn::ItemImpl = syn::parse2(input)?;
|
|
|
|
let type_name = &impl_block.self_ty;
|
|
let mut fields = Vec::new();
|
|
|
|
for item in &impl_block.items {
|
|
let syn::ImplItem::Fn(func) = item else {
|
|
continue;
|
|
};
|
|
|
|
if !func.attrs.iter().any(|attr| attr.path().is_ident("getter")) {
|
|
continue;
|
|
}
|
|
|
|
fields.push(&func.sig.ident);
|
|
}
|
|
|
|
let output = quote::quote! {
|
|
#impl_block
|
|
|
|
impl crate::repr::Repr for #type_name {
|
|
fn fmt(&self, f: &mut crate::repr::Formatter<'_>) -> std::fmt::Result {
|
|
use crate::repr::WriteExt as _;
|
|
|
|
f.class::<Self>(&[
|
|
#( (stringify!(#fields), &self.#fields()) ),*
|
|
])
|
|
}
|
|
}
|
|
};
|
|
|
|
Ok(output)
|
|
}
|