starlark 0.14.0

An implementation of the Starlark language in Rust.
Documentation
/*
 * Copyright 2019 The Starlark in Rust Authors.
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

//! Support for serialization and deserialization of Starlark values (pagable).
//!
//! This module provides the infrastructure needed to serialize and deserialize
//! Starlark heaps and values.
//!
//! ## Challenge: Type Inventory Registration
//!
//! During deserialization, we need to know which deserialization function to use
//! for each Starlark value type. This is solved by using the `inventory` crate
//! to register a mapping from type identifiers to vtables at compile time.
//!
//! The type identifier is `std::any::type_name<T>()` for the Rust type that
//! defines the Starlark value.

pub(crate) mod error;

#[cfg(feature = "pagable")]
pub(crate) mod vtable_registry;
#[cfg(not(feature = "pagable"))]
pub(crate) mod vtable_registry_stub;

#[cfg(feature = "pagable")]
pub(crate) use vtable_registry::DeserTypeId;
#[cfg(feature = "pagable")]
pub(crate) use vtable_registry::lookup_vtable;
#[cfg(not(feature = "pagable"))]
pub(crate) use vtable_registry_stub::DeserTypeId;
#[cfg(not(feature = "pagable"))]
pub(crate) use vtable_registry_stub::lookup_vtable;

/// Runtime-registration marker trait for vtable lookup at deserialize time.
pub mod vtable_register;

pub use vtable_register::VtableRegistered;

pub(crate) mod static_value;
pub use static_value::StaticValueEntry;
pub use static_value::StaticValueRegistered;
#[allow(unused_imports)]
pub(crate) use static_value::get_static_value_id;

pub(crate) mod heap_ref_id;
pub(crate) mod serialized_frozen_value;
pub(crate) mod starlark_deserialize;
pub(crate) mod starlark_deserialize_context;
pub(crate) mod starlark_pagable;
pub(crate) mod starlark_serialize;
pub(crate) mod starlark_serialize_context;

mod starlark_pagable_impls;

// Re-export public types
pub use starlark_deserialize::StarlarkDeserialize;
pub use starlark_deserialize::StarlarkDeserializeContext;
pub use starlark_deserialize_context::StarlarkDeserializerImpl;
pub use starlark_pagable::StarlarkPagable;
pub use starlark_pagable_impls::SmallMapKeyDeserialize;
pub use starlark_serialize::StarlarkSerialize;
pub use starlark_serialize::StarlarkSerializeContext;
pub use starlark_serialize_context::StarlarkSerializerImpl;

/// Sealed marker emitted by `#[starlark_pagable_typetag]` on a trait. The
/// impl form requires it, pairing the two structurally.
pub trait StarlarkTypetagTraitMarker: __private::StarlarkTypetagTraitSealed {}

#[doc(hidden)]
pub mod __private {
    /// Sealed — do not implement directly.
    pub trait StarlarkTypetagTraitSealed {}
}

#[cfg(all(test, feature = "pagable"))]
mod tests;