Core
Generated from the type stubs and docstrings. Do not edit by hand.
AvroRegistrySerde
Section titled “AvroRegistrySerde”check_compatibility
Section titled “check_compatibility”check_compatibility(self, schema: str, version: Optional[str] = None) -> Ok[bool] | Err[SerdeError]delete_version
Section titled “delete_version”delete_version(self, version: int) -> Ok[bool] | Err[SerdeError]deserialize
Section titled “deserialize”deserialize(self, data: bytes) -> Ok[Any] | Err[SerdeError]Deserialize Confluent wire-format bytes, fetching schema from registry by ID.
deserialize_many
Section titled “deserialize_many”deserialize_many(self, bytes_list: BytesList) -> IListDeserialize BytesList to IList[Either[DeserializationError, obj]].
deserialize_many_objects
Section titled “deserialize_many_objects”deserialize_many_objects(self, bytes_list: BytesList) -> IListDeserialize BytesList directly to IList[obj], raising DeserializationError on first failure.
for_topic
Section titled “for_topic”for_topic(registry_url: str, topic: str, schema: str, is_key: bool = False, username: Optional[str] = None, password: Optional[str] = None, ca_path: Optional[str] = None, cert_path: Optional[str] = None, key_path: Optional[str] = None) -> AvroRegistrySerdeConvenience constructor - derives subject as “{topic}-value” or “{topic}-key”.
get_schema_by_version
Section titled “get_schema_by_version”get_schema_by_version(self, version: int) -> Ok[str] | Err[SerdeError]list_versions
Section titled “list_versions”list_versions(self) -> Ok[list[int]] | Err[SerdeError]register
Section titled “register”register(self) -> Ok[int] | Err[SerdeError]Eagerly register this serde’s schema with the registry. Returns Either[SerializationError, int] where int is the assigned schema ID. Not required - serialize() registers lazily on first call.
serialize
Section titled “serialize”serialize(self, obj: Any) -> Ok[bytes] | Err[SerdeError]serialize_many
Section titled “serialize_many”serialize_many(self, items: IList) -> IListserialize_many_bytes
Section titled “serialize_many_bytes”serialize_many_bytes(self, items: IList) -> BytesListSerialize IList directly to BytesList, raising SerializationError on first failure.
subject
Section titled “subject”subject(self) -> strAvroSerde
Section titled “AvroSerde”deserialize
Section titled “deserialize”deserialize(self, data: bytes) -> Ok[Any] | Err[SerdeError]deserialize_many
Section titled “deserialize_many”deserialize_many(self, bytes_list: BytesList) -> IListserialize
Section titled “serialize”serialize(self, obj: Any) -> Ok[bytes] | Err[SerdeError]serialize_many
Section titled “serialize_many”serialize_many(self, items: IList) -> IListserialize_many_bytes
Section titled “serialize_many_bytes”serialize_many_bytes(self, items: IList) -> BytesListSerialize IList directly to BytesList, raising SerializationError on first failure.
BytesList
Section titled “BytesList”Immutable list of byte sequences (Vec<Vec<u8>>).
Each element is a bytes object in Python. Supports conversion to
IList[bytes] via to_ilist().
append
Section titled “append”append(self, item: bytes) -> BytesListempty() -> BytesListfrom_packed
Section titled “from_packed”from_packed(buf, count)Build from one length-framed buffer: count records, each a
little-endian u32 length followed by that many bytes. Lets the Kafka
consumer hand the whole batch across the extension boundary as a single
bytes object - one copy + one parse - instead of allocating a bytes
per record and re-extracting each. count lets us pre-size inner.
get(self, index: int) -> Some[bytes] | _Nothingis_empty
Section titled “is_empty”is_empty(self) -> boollength
Section titled “length”length(self) -> intto_ilist
Section titled “to_ilist”to_ilist(self) -> IList[bytes]to_list
Section titled “to_list”to_list(self) -> list[bytes]to_packed
Section titled “to_packed”to_packed(self) -> bytesExport as one length-framed bytes object:
count * (u32 little-endian length + payload).
DeserializationError
Section titled “DeserializationError”Duration
Section titled “Duration”A typed time-span value backed by an i64 nanosecond count.
Mirrors Scala’s FiniteDuration - a precise, immutable quantity of time
with unit-converting constructors and full arithmetic support.
Examples
Section titled “Examples”from pyrula import Duration
d = Duration.seconds(1) + Duration.millis(500)assert d.to_millis() == 1500
import datetimeassert Duration.seconds(1).to_timedelta() == datetime.timedelta(seconds=1)days(n: float) -> DurationCreate a Duration from a number of days (fractional days allowed).
from_timedelta
Section titled “from_timedelta”from_timedelta(td: Any) -> DurationCreate a Duration from a Python datetime.timedelta.
hours(n: float) -> DurationCreate a Duration from a number of hours (fractional hours allowed).
micros
Section titled “micros”micros(n: int) -> DurationCreate a Duration from a microsecond count.
millis
Section titled “millis”millis(n: int) -> DurationCreate a Duration from a millisecond count.
minutes
Section titled “minutes”minutes(n: float) -> DurationCreate a Duration from a number of minutes (fractional minutes allowed).
nanos(n: int) -> DurationCreate a Duration from a nanosecond count.
seconds
Section titled “seconds”seconds(n: float) -> DurationCreate a Duration from a number of seconds (fractional seconds allowed).
to_millis
Section titled “to_millis”to_millis(self) -> intMilliseconds, truncating sub-millisecond precision.
to_nanos
Section titled “to_nanos”to_nanos(self) -> intThe raw nanosecond count.
to_seconds
Section titled “to_seconds”to_seconds(self) -> floatSeconds as a float.
to_timedelta
Section titled “to_timedelta”to_timedelta(self) -> AnyConvert to a Python datetime.timedelta.
Resolution is microseconds (Python’s timedelta does not support
nanosecond precision). Sub-microsecond nanos are truncated.
Either
Section titled “Either”The base of the Either result type: an Ok value or an Err error.
Ok and Err subclass Either, the same way Scala’s Either is subclassed
by Right and Left. So isinstance(x, Either) holds for both cases and
Either[A, E] is a real generic alias. Either is abstract: construct values
through Either.ok / Either.err (or Ok / Err directly), not Either(...).
cond(condition: bool, ok: T, err: E) -> Either[T, E]Ok(ok) if condition else Err(err).
err(error: E) -> Err[E]Err(error).
ok(value: T) -> Ok[T]Ok(value).
sequence
Section titled “sequence”sequence(values: Iterable[Either[T, E]]) -> Either[list[T], E]Ok of every value, or the first Err encountered.
try_of
Section titled “try_of”try_of(f: Callable[[], T]) -> Either[T, Exception]Ok(f()), or Err(exc) if f raises an Exception. A BaseException
(KeyboardInterrupt, SystemExit) propagates rather than being captured.
Fields:
error: E
flat_map
Section titled “flat_map”flat_map(self, _f) -> Err[E]fold(self, err: Callable[..., Any], _ok) -> Anyget_or_else
Section titled “get_or_else”get_or_else(self, default: Any) -> Anyis_err
Section titled “is_err”is_err(self) -> boolis_ok(self) -> boolmap(self, _f) -> Err[E]map_err
Section titled “map_err”map_err(self, f: Callable[..., Any]) -> Err[Any]or_else
Section titled “or_else”or_else(self, default: Any) -> Anyrecover
Section titled “recover”recover(self, f: Callable[..., Any]) -> Anyto_option
Section titled “to_option”to_option(self) -> _Nothingunwrap_or_raise
Section titled “unwrap_or_raise”unwrap_or_raise(self, exc: Any = None) -> AnyWith exc: raise it. Without: raise the contained error if it is an
exception, else RuntimeError - so result.unwrap_or_raise() replaces
the if result.is_err(): raise result.error boilerplate.
Failure
Section titled “Failure”Fields:
error: BaseException
flat_map
Section titled “flat_map”flat_map(self, _f) -> Failurefold(self, failure: Callable[..., Any], _success) -> Anyget_or_else
Section titled “get_or_else”get_or_else(self, default: Any) -> Anyis_failure
Section titled “is_failure”is_failure(self) -> boolis_success
Section titled “is_success”is_success(self) -> boolmap(self, _f) -> Failureor_else
Section titled “or_else”or_else(self, default: Any) -> Anyrecover
Section titled “recover”recover(self, f: Callable[..., Any]) -> Anyto_either
Section titled “to_either”to_either(self) -> Err[Any]FloatList
Section titled “FloatList”Immutable list of f64 values with typed scalar operations.
Scalar methods (add_scalar, mul_scalar, min, max, sum) run on
rayon’s thread pool without touching the GIL. Callback-based methods
(map_float, filter, fold_left) require the GIL for the Python closure.
abs_vals
Section titled “abs_vals”abs_vals(self) -> FloatListadd_scalar
Section titled “add_scalar”add_scalar(self, n: float) -> FloatListclamp_vals
Section titled “clamp_vals”clamp_vals(self, lo: float, hi: float) -> FloatListdiv_scalar
Section titled “div_scalar”div_scalar(self, n: float) -> FloatListempty() -> FloatListfilter
Section titled “filter”filter(self, pred: Callable[[float], bool]) -> FloatListfold_left
Section titled “fold_left”fold_left(self, initial: Any, f: Callable[..., Any]) -> Anyis_empty
Section titled “is_empty”is_empty(self) -> boollength
Section titled “length”length(self) -> intmap_float
Section titled “map_float”map_float(self, f: Callable[[float], float]) -> FloatListmax(self) -> floatmean(self) -> floatmin(self) -> floatmul_scalar
Section titled “mul_scalar”mul_scalar(self, n: float) -> FloatListstd_dev
Section titled “std_dev”std_dev(self) -> floatsub_scalar
Section titled “sub_scalar”sub_scalar(self, n: float) -> FloatListsum(self) -> floatto_ilist
Section titled “to_ilist”to_ilist(self) -> IList[float]to_list
Section titled “to_list”to_list(self) -> list[float]zip_add
Section titled “zip_add”zip_add(self, other: FloatList) -> FloatListzip_mul
Section titled “zip_mul”zip_mul(self, other: FloatList) -> FloatListImmutable persistent list - structural sharing via im-rs.
Arc<Py
append
Section titled “append”append(self, item: T) -> IList[T]collect_err
Section titled “collect_err”collect_err(self) -> IList[Any]Extract all Err values from an IList of Either[Ok, Err].
collect_ok
Section titled “collect_ok”collect_ok(self) -> IList[Any]concat
Section titled “concat”concat(self, other: IList[T]) -> IList[T]distinct
Section titled “distinct”distinct(self) -> IList[T]drop(self, n: int) -> IList[T]empty() -> IList[Any]filter
Section titled “filter”filter(self, pred: Callable[..., bool]) -> IList[T]find(self, pred: Callable[..., bool]) -> Some[T] | _Nothingflat_map
Section titled “flat_map”flat_map(self, f: Callable[..., Any]) -> IList[Any]fold_left
Section titled “fold_left”fold_left(self, initial: Any, f: Callable[..., Any]) -> Anyhead(self) -> Some[T] | _Nothingis_empty
Section titled “is_empty”is_empty(self) -> boollast(self) -> Some[T] | _Nothinglength
Section titled “length”length(self) -> intmap(self, f: Callable[..., Any]) -> IList[Any]partition_either
Section titled “partition_either”partition_either(self) -> tuple[IList[Any], IList[Any]]Partition an IList of Either[Ok, Err] into (oks, errs).
prepend
Section titled “prepend”prepend(self, item: T) -> IList[T]tail(self) -> IList[T]take(self, n: int) -> IList[T]to_list
Section titled “to_list”to_list(self) -> list[T]zip(self, other: IList[Any]) -> IList[tuple[T, Any]]Pair each element with the element at the same index in other,
stopping at the shorter of the two lists. Yields (self, other) tuples.
contains
Section titled “contains”contains(self, key: K) -> boolempty() -> IMap[Any, Any]filter_values
Section titled “filter_values”filter_values(self, pred: Callable[[V], bool]) -> IMap[K, V]get(self, key: K) -> Some[V] | _NothingReturn the value for key, or nothing() if not present.
is_empty
Section titled “is_empty”is_empty(self) -> boolitems(self) -> IList[tuple[K, V]]keys(self) -> IList[K]length
Section titled “length”length(self) -> intmap_values
Section titled “map_values”map_values(self, f: Callable[[V], Any]) -> IMap[K, Any]merge(self, other: IMap[K, V]) -> IMap[K, V]remove
Section titled “remove”remove(self, key: K) -> IMap[K, V]set(self, key: K, value: V) -> IMap[K, V]to_dict
Section titled “to_dict”to_dict(self) -> dictConvert to a standard Python dict.
values
Section titled “values”values(self) -> IList[V]Immutable persistent set - structural sharing via im-rs HashSet.
add(self, item: T) -> ISet[T]Return a new ISet with item added. No-op if already present.
contains
Section titled “contains”contains(self, item: T) -> boolReturn true if item is in this set.
difference
Section titled “difference”difference(self, other: ISet[T]) -> ISet[T]Return a new ISet with elements of this set that are not in other.
empty() -> ISet[Any]filter
Section titled “filter”filter(self, pred: Callable[[T], bool]) -> ISet[T]Return a new ISet containing only elements for which pred returns true.
intersection
Section titled “intersection”intersection(self, other: ISet[T]) -> ISet[T]Return a new ISet containing only elements present in both sets.
is_empty
Section titled “is_empty”is_empty(self) -> boolis_subset_of
Section titled “is_subset_of”is_subset_of(self, other: ISet[T]) -> boolReturn true if every element of this set is also in other.
map(self, f: Callable[[T], Any]) -> ISet[Any]Apply f to each element and return a new ISet of the results.
remove
Section titled “remove”remove(self, item: T) -> ISet[T]Return a new ISet with item removed. No-op if absent.
size(self) -> intNumber of elements in this set.
to_ilist
Section titled “to_ilist”to_ilist(self) -> IList[T]Convert to an IList. Order is unspecified (hash set iteration order).
to_set
Section titled “to_set”to_set(self) -> set[T]Convert to a standard Python set.
union(self, other: ISet[T]) -> ISet[T]Return a new ISet that is the union of this set and other.
IntList
Section titled “IntList”Immutable list of i64 values with typed scalar operations.
Scalar methods (add_scalar, mul_scalar, min, max, sum) run on
rayon’s thread pool without touching the GIL. Callback-based methods
(map_int, filter, fold_left) require the GIL for the Python closure.
abs_vals
Section titled “abs_vals”abs_vals(self) -> IntListadd_scalar
Section titled “add_scalar”add_scalar(self, n: int) -> IntListclamp_vals
Section titled “clamp_vals”clamp_vals(self, lo: int, hi: int) -> IntListdiv_scalar
Section titled “div_scalar”div_scalar(self, n: int) -> IntListempty() -> IntListfilter
Section titled “filter”filter(self, pred: Callable[[int], bool]) -> IntListfold_left
Section titled “fold_left”fold_left(self, initial: Any, f: Callable[..., Any]) -> Anyis_empty
Section titled “is_empty”is_empty(self) -> boollength
Section titled “length”length(self) -> intmap_int
Section titled “map_int”map_int(self, f: Callable[[int], int]) -> IntListmax(self) -> intmean(self) -> floatmin(self) -> intmul_scalar
Section titled “mul_scalar”mul_scalar(self, n: int) -> IntListstd_dev
Section titled “std_dev”std_dev(self) -> floatsub_scalar
Section titled “sub_scalar”sub_scalar(self, n: int) -> IntListsum(self) -> intto_ilist
Section titled “to_ilist”to_ilist(self) -> IList[int]to_list
Section titled “to_list”to_list(self) -> list[int]zip_add
Section titled “zip_add”zip_add(self, other: IntList) -> IntListzip_mul
Section titled “zip_mul”zip_mul(self, other: IntList) -> IntListIntSet
Section titled “IntSet”Immutable set of non-negative integers backed by a Roaring bitmap.
Set algebra (union, intersection, difference, cardinality, …) runs
entirely in Rust over compressed bitmaps - no per-element Python callbacks
and no GIL contention. Construction and to_list cross the boundary once per
element, the same as building a Python set; the payoff is the operations.
add(self, value: int) -> IntSetcardinality
Section titled “cardinality”cardinality(self) -> intcontains
Section titled “contains”contains(self, value: int) -> booldifference
Section titled “difference”difference(self, other: IntSet) -> IntSetempty() -> IntSetfrom_bytes
Section titled “from_bytes”from_bytes(data: bytes) -> IntSetReconstruct an IntSet from to_bytes output (Roaring portable format).
intersection
Section titled “intersection”intersection(self, other: IntSet) -> IntSetis_disjoint
Section titled “is_disjoint”is_disjoint(self, other: IntSet) -> boolis_empty
Section titled “is_empty”is_empty(self) -> boolis_subset
Section titled “is_subset”is_subset(self, other: IntSet) -> boolremove
Section titled “remove”remove(self, value: int) -> IntSetsymmetric_difference
Section titled “symmetric_difference”symmetric_difference(self, other: IntSet) -> IntSetto_bytes
Section titled “to_bytes”to_bytes(self) -> bytesSerialize to the Roaring portable byte format, suitable for durable checkpoints or interop with other Roaring implementations.
to_list
Section titled “to_list”to_list(self) -> list[int]union(self, other: IntSet) -> IntSetInvalid
Section titled “Invalid”Fields:
errors: list[E]Always a Pythonlistof error values.
fold(self, invalid_fn, _valid_fn)fold(invalid_fn, valid_fn) - calls invalid_fn(errors).
get_or_else
Section titled “get_or_else”get_or_else(self, default)Return default.
is_invalid
Section titled “is_invalid”is_invalid(self)is_valid
Section titled “is_valid”is_valid(self)map(self, _f)Pass-through: map on Invalid is a no-op (returns a fresh copy).
map_err
Section titled “map_err”map_err(self, f)Invalid(f(errors)). f receives the errors list and must return a
new value (usually a list) to use as the new error collection.
to_either
Section titled “to_either”to_either(self)Err(errors_list).
zip(self, other)Combine with other. Concatenates error lists from both sides.
Valid on other contributes no errors.
JsonSchemaRegistrySerde
Section titled “JsonSchemaRegistrySerde”check_compatibility
Section titled “check_compatibility”check_compatibility(self, schema: str, version: Optional[str] = None) -> Ok[bool] | Err[SerdeError]delete_version
Section titled “delete_version”delete_version(self, version: int) -> Ok[bool] | Err[SerdeError]deserialize
Section titled “deserialize”deserialize(self, data: bytes) -> Ok[Any] | Err[SerdeError]deserialize_many
Section titled “deserialize_many”deserialize_many(self, bytes_list: BytesList) -> IListdeserialize_many_objects
Section titled “deserialize_many_objects”deserialize_many_objects(self, bytes_list: BytesList) -> IListfor_topic
Section titled “for_topic”for_topic(registry_url: str, topic: str, schema: str, is_key: bool = False, username: Optional[str] = None, password: Optional[str] = None, ca_path: Optional[str] = None, cert_path: Optional[str] = None, key_path: Optional[str] = None) -> JsonSchemaRegistrySerdeget_schema_by_version
Section titled “get_schema_by_version”get_schema_by_version(self, version: int) -> Ok[str] | Err[SerdeError]list_versions
Section titled “list_versions”list_versions(self) -> Ok[list[int]] | Err[SerdeError]register
Section titled “register”register(self) -> Ok[int] | Err[SerdeError]serialize
Section titled “serialize”serialize(self, obj: Any) -> Ok[bytes] | Err[SerdeError]serialize_many
Section titled “serialize_many”serialize_many(self, items: IList) -> IListserialize_many_bytes
Section titled “serialize_many_bytes”serialize_many_bytes(self, items: IList) -> BytesListsubject
Section titled “subject”subject(self) -> strJsonSerde
Section titled “JsonSerde”deserialize
Section titled “deserialize”deserialize(self, data: bytes) -> Ok[Any] | Err[SerdeError]deserialize_many
Section titled “deserialize_many”deserialize_many(self, bytes_list: BytesList) -> IListdeserialize_many_raw
Section titled “deserialize_many_raw”deserialize_many_raw(self, bytes_list: BytesList) -> IListFail-fast deserialization from BytesList returning IList directly.
serialize
Section titled “serialize”serialize(self, obj: Any) -> Ok[bytes] | Err[SerdeError]serialize_many
Section titled “serialize_many”serialize_many(self, items: IList) -> IListserialize_many_raw
Section titled “serialize_many_raw”serialize_many_raw(self, items: IList) -> BytesListFail-fast serialization returning BytesList directly.
NonEmptyList
Section titled “NonEmptyList”NonEmptyList - a list provably containing at least one element.
head, last, and reduce are total (return A, never Option) because
the non-empty invariant is upheld by the constructor. from_list converts
a plain list or IList into Option[NonEmptyList], making the emptiness
check explicit at the boundary.
append
Section titled “append”append(self, item: T) -> NonEmptyList[T]Append an element to the end, returning a new NonEmptyList.
flat_map
Section titled “flat_map”flat_map(self, f: Callable[[T], NonEmptyList[Any]]) -> NonEmptyList[Any]flat_map - each element maps to a NonEmptyList; results are
concatenated. The overall result is still non-empty (at least the
first mapped NEL contributes one element).
fold_left
Section titled “fold_left”fold_left(self, init: Any, f: Callable[[Any, T], Any]) -> AnyLeft fold with an explicit initial accumulator.
from_list
Section titled “from_list”from_list(items: IList[T] | list[T]) -> Option[NonEmptyList[T]]Convert an IList[T] or list[T] into Option[NonEmptyList[T]].
Returns Some(nel) when the input is non-empty, Nothing otherwise.
head(self) -> TThe first element - total (never Option) because the list is non-empty.
last(self) -> TThe last element - total for the same reason.
length
Section titled “length”length(self) -> intNumber of elements (always >= 1).
map(self, f: Callable[[T], Any]) -> NonEmptyList[Any]Element-wise map - result is still a NonEmptyList.
of(head: T, *tail: T) -> NonEmptyList[T]Alias for NonEmptyList(head, *tail).
prepend
Section titled “prepend”prepend(self, item: T) -> NonEmptyList[T]Prepend an element to the front, returning a new NonEmptyList.
reduce
Section titled “reduce”reduce(self, f: Callable[[T, T], T]) -> TFold the list with f, seeded by head. Total - non-empty list always
has at least the head to return.
tail(self) -> IList[T]All elements except the first, as an IList (may be empty).
to_ilist
Section titled “to_ilist”to_ilist(self) -> IList[T]Convert to an IList.
to_list
Section titled “to_list”to_list(self) -> list[T]Convert to a plain Python list.
Fields:
value: T
flat_map
Section titled “flat_map”flat_map(self, f: Callable[..., Any]) -> Anyfold(self, _err, ok: Callable[..., Any]) -> Anyget_or_else
Section titled “get_or_else”get_or_else(self, _default) -> Tis_err
Section titled “is_err”is_err(self) -> boolis_ok(self) -> boolmap(self, f: Callable[..., Any]) -> Ok[Any]map_err
Section titled “map_err”map_err(self, _f) -> Ok[T]or_else
Section titled “or_else”or_else(self, _default) -> Ok[T]recover
Section titled “recover”recover(self, _f) -> Ok[T]to_option
Section titled “to_option”to_option(self) -> Some[T]unwrap_or_raise
Section titled “unwrap_or_raise”unwrap_or_raise(self, exc: Any = None) -> TOption
Section titled “Option”The base of the Option type: a Some value or Nothing.
Some and Nothing subclass Option, mirroring Scala’s Option subclassed
by Some and None. So isinstance(x, Option) holds for both cases and
Option[T] is a real generic alias. Option is abstract: construct values
through Option.of / Option.when (or Some / Nothing directly), not
Option(...).
from_callable
Section titled “from_callable”from_callable(f: Callable[[], T]) -> Option[T]Some(f()) if f returns a non-None value; Nothing if f returns
None or raises an Exception. A BaseException (KeyboardInterrupt,
SystemExit) propagates rather than being captured.
of(value: Optional[T]) -> Option[T]Some(value) if value is not None, else Nothing.
sequence
Section titled “sequence”sequence(values: Iterable[Option[T]]) -> Option[list[T]]Some of every value in the iterable, or Nothing if any element is Nothing.
when(condition: bool, value: T) -> Option[T]Some(value) if condition is True, else Nothing.
ProtobufRegistrySerde
Section titled “ProtobufRegistrySerde”check_compatibility
Section titled “check_compatibility”check_compatibility(self, proto_source: str, version: Optional[str] = None) -> Ok[bool] | Err[SerdeError]delete_version
Section titled “delete_version”delete_version(self, version: int) -> Ok[bool] | Err[SerdeError]deserialize
Section titled “deserialize”deserialize(self, data: bytes) -> Ok[Any] | Err[SerdeError]deserialize_many
Section titled “deserialize_many”deserialize_many(self, bytes_list: BytesList) -> IListdeserialize_many_objects
Section titled “deserialize_many_objects”deserialize_many_objects(self, bytes_list: BytesList) -> IListfor_topic
Section titled “for_topic”for_topic(registry_url: str, topic: str, file_descriptor_set: bytes, message_name: str, is_key: bool = False, proto_source: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, ca_path: Optional[str] = None, cert_path: Optional[str] = None, key_path: Optional[str] = None) -> ProtobufRegistrySerdeget_schema_by_version
Section titled “get_schema_by_version”get_schema_by_version(self, version: int) -> Ok[str] | Err[SerdeError]list_versions
Section titled “list_versions”list_versions(self) -> Ok[list[int]] | Err[SerdeError]register
Section titled “register”register(self) -> Ok[int] | Err[SerdeError]serialize
Section titled “serialize”serialize(self, obj: Any) -> Ok[bytes] | Err[SerdeError]serialize_many
Section titled “serialize_many”serialize_many(self, items: IList) -> IListserialize_many_bytes
Section titled “serialize_many_bytes”serialize_many_bytes(self, items: IList) -> BytesListserialize_with_id
Section titled “serialize_with_id”serialize_with_id(self, obj: Any, schema_id: int) -> Ok[bytes] | Err[SerdeError]subject
Section titled “subject”subject(self) -> strSerdeError
Section titled “SerdeError”SerializationError
Section titled “SerializationError”Fields:
value: T
filter
Section titled “filter”filter(self, pred: Callable[..., bool]) -> Anyflat_map
Section titled “flat_map”flat_map(self, f: Callable[..., Any]) -> Anyfold(self, _nothing_val, some_fn: Callable[..., Any]) -> Anyget_or_else
Section titled “get_or_else”get_or_else(self, _default) -> Tis_empty
Section titled “is_empty”is_empty(self) -> boolis_nothing
Section titled “is_nothing”is_nothing(self) -> boolis_some
Section titled “is_some”is_some(self) -> boolmap(self, f: Callable[..., Any]) -> Some[Any]or_else
Section titled “or_else”or_else(self, _default) -> Some[T]to_either
Section titled “to_either”to_either(self, _left) -> Ok[T]to_list
Section titled “to_list”to_list(self) -> IList[T]Success
Section titled “Success”Fields:
value: T
flat_map
Section titled “flat_map”flat_map(self, f: Callable[..., Any]) -> Anyfold(self, _failure, success: Callable[..., Any]) -> Anyget_or_else
Section titled “get_or_else”get_or_else(self, _default) -> Tis_failure
Section titled “is_failure”is_failure(self) -> boolis_success
Section titled “is_success”is_success(self) -> boolmap(self, f: Callable[..., Any]) -> Anyor_else
Section titled “or_else”or_else(self, _default) -> Success[T]recover
Section titled “recover”recover(self, _f) -> Success[T]to_either
Section titled “to_either”to_either(self) -> Ok[T]The base of the Try result type: a Success value or a Failure exception.
Success and Failure subclass Try, the same way Scala’s Try is subclassed
by Success and Failure. So isinstance(x, Try) holds for both cases and
Try[A] is a real generic alias. Try is abstract: construct values through
Try.apply / Try.of (or Success / Failure directly), not Try(...).
apply(f: Callable[[], T]) -> Try[T]Success(f()), or Failure(exc) if f raises an Exception. A
BaseException (KeyboardInterrupt, SystemExit) propagates rather than
being captured.
of(f: Callable[[], T]) -> Try[T]Alias for Try.apply.
sequence
Section titled “sequence”sequence(values: Iterable[Try[T]]) -> Try[list[T]]Success of every value, or the first Failure encountered.
Fields:
value: T
fold(self, _invalid_fn, valid_fn)fold(invalid_fn, valid_fn) - calls valid_fn(value).
get_or_else
Section titled “get_or_else”get_or_else(self, _default)Return value directly.
is_invalid
Section titled “is_invalid”is_invalid(self)is_valid
Section titled “is_valid”is_valid(self)map(self, f)Valid(f(value)).
map_err
Section titled “map_err”map_err(self, _f)Pass-through: map_err on Valid is a no-op.
to_either
Section titled “to_either”to_either(self)Ok(value).
zip(self, other)Combine with other. Both Valid → Valid((self.value, other.value)).
Any Invalid → Invalid with that side’s error list.
Validated
Section titled “Validated”Like Either, but zip accumulates errors instead of short-circuiting.
Valid and Invalid subclass Validated just as Scala’s Valid/Invalid
subclass Validated. Build values through the factory methods; Validated
itself is abstract - constructing it directly is an error.
cond(condition: bool, value: T, error: E) -> Validated[T, E]Valid(value) if condition, else Invalid([error]).
from_either
Section titled “from_either”from_either(either: Either[T, E]) -> Validated[T, E]Convert an Either into a Validated.
Ok(v) → Valid(v); Err(e) → Invalid([e]).
invalid
Section titled “invalid”invalid(error: E) -> Validated[T, E]Invalid([error]). If error is already a list it is stored as-is
(shallow copy); otherwise it is wrapped: [error].
valid(value: T) -> Validated[T, E]Valid(value).
map(self, f: Callable[[T], Any]) -> Validated[Any, E]map_err
Section titled “map_err”map_err(self, f: Callable[[list[E]], Any]) -> Validated[T, Any]zip(self, other: Validated[Any, E]) -> Validated[Any, E]fold(self, invalid: Callable[[list[E]], Any], valid: Callable[[T], Any]) -> Anyget_or_else
Section titled “get_or_else”get_or_else(self, default: T) -> Tto_either
Section titled “to_either”to_either(self) -> Either[T, list[E]]is_valid
Section titled “is_valid”is_valid(self) -> boolis_invalid
Section titled “is_invalid”is_invalid(self) -> boolFunctions
Section titled “Functions”case(cls: type[T]) -> type[T]do(func: Callable[..., Any]) -> Callable[..., Any]do_async
Section titled “do_async”do_async(func: Callable[..., Any]) -> Callable[..., Any]flow(*funcs: Callable[..., Any]) -> Callable[..., Any]match(value: Any) -> Callable[..., Any]newtype
Section titled “newtype”newtype(name: str, base_type: type[T]) -> type[T]newtype_strict
Section titled “newtype_strict”newtype_strict(name: str, base_type: type[T], validate: Optional[Callable[..., bool]] = None, err_msg: Optional[str] = None) -> type[T]on(typ: type[T], handler: Callable[..., Any]) -> Anypartial
Section titled “partial”partial(f: Callable[..., Any], *args: Any, **kwargs: Any) -> Callable[..., Any]pipe(value: Any, *funcs: Callable[..., Any]) -> Anysealed
Section titled “sealed”sealed(cls: type[T]) -> type[T]