1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
 * Copyright 2018 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.
 */

//! Defines a runtime Starlark value ([`Value`]) and traits for defining custom values ([`StarlarkValue`]).
//!
//! This module contains code for working with Starlark values:
//!
//! * Most code dealing with Starlark will use [`Value`], as it represents the fundamental values used in
//!   Starlark. When frozen, they become [`FrozenValue`].
//! * Values are garbage-collected, so a given [`Value`] lives on a [`Heap`].
//! * Rust values (e.g. [`String`], [`Vec`]) can be added to the [`Heap`] with [`AllocValue`],
//!   and deconstructed from a [`Value`] with [`UnpackValue`]
//!   (or specialised methods like [`unpack_str`](Value::unpack_str)).
//! * To define your own Rust data type that can live in a [`Value`] it must implement the [`StarlarkValue`]
//!   trait.
//! * All the nested modules represent the built-in Starlark values. These are all defined using [`StarlarkValue`],
//!   so may serve as interesting inspiration for writing your own values, in addition to occurring in Starlark programs.

pub use starlark_derive::starlark_attrs;
pub use starlark_derive::starlark_value;
pub use starlark_derive::Freeze;
pub use starlark_derive::NoSerialize;
pub use starlark_derive::StarlarkAttrs;
pub use starlark_derive::Trace;
pub use starlark_derive::UnpackValue;

pub use crate::any::AnyLifetime;
pub use crate::any::ProvidesStaticType;
pub use crate::coerce::Coerce;
pub use crate::values::alloc_value::AllocFrozenValue;
pub use crate::values::alloc_value::AllocValue;
pub use crate::values::demand::Demand;
pub use crate::values::error::ValueError;
pub use crate::values::freeze::Freeze;
pub use crate::values::frozen_ref::FrozenRef;
pub use crate::values::frozen_ref::OwnedFrozenRef;
pub use crate::values::iter::StarlarkIterator;
pub use crate::values::layout::complex::ValueTypedComplex;
pub use crate::values::layout::heap::heap_type::Freezer;
pub use crate::values::layout::heap::heap_type::FrozenHeap;
pub use crate::values::layout::heap::heap_type::FrozenHeapRef;
pub use crate::values::layout::heap::heap_type::Heap;
pub use crate::values::layout::heap::heap_type::Tracer;
pub use crate::values::layout::heap::profile::aggregated::AggregateHeapProfileInfo;
pub use crate::values::layout::identity::ValueIdentity;
pub use crate::values::layout::static_string::constant_string;
pub use crate::values::layout::static_string::StarlarkStrNRepr;
pub use crate::values::layout::typed::string::FrozenStringValue;
pub use crate::values::layout::typed::string::StringValue;
pub use crate::values::layout::typed::string::StringValueLike;
pub use crate::values::layout::typed::FrozenValueTyped;
pub use crate::values::layout::typed::ValueTyped;
pub use crate::values::layout::value::FrozenValue;
pub use crate::values::layout::value::Value;
pub use crate::values::layout::value::ValueLike;
pub use crate::values::owned::OwnedFrozenValue;
pub use crate::values::owned::OwnedFrozenValueTyped;
pub use crate::values::trace::Trace;
pub use crate::values::traits::ComplexValue;
pub use crate::values::traits::StarlarkValue;
pub use crate::values::types::any;
pub use crate::values::types::array;
pub use crate::values::types::bool;
pub use crate::values::types::dict;
pub use crate::values::types::enumeration;
pub use crate::values::types::exported_name;
pub use crate::values::types::float;
pub use crate::values::types::function;
pub use crate::values::types::int;
pub use crate::values::types::list;
pub use crate::values::types::list_or_tuple;
pub use crate::values::types::none;
pub use crate::values::types::range;
pub use crate::values::types::record;
pub use crate::values::types::starlark_value_as_type;
pub use crate::values::types::string;
pub use crate::values::types::structs;
pub use crate::values::types::tuple;
pub use crate::values::unpack::UnpackValue;
pub use crate::values::unpack::ValueOf;
pub use crate::values::value_of_unchecked::ValueOfUnchecked;

mod alloc_value;
mod comparison;
pub(crate) mod demand;
pub(crate) mod error;
mod freeze;
pub(crate) mod frozen_ref;
mod index;
pub(crate) mod iter;
pub(crate) mod layout;
pub(crate) mod num;
mod owned;
pub(crate) mod recursive_repr_or_json_guard;
mod stack_guard;
pub(crate) mod starlark_type_id;
mod trace;
pub(crate) mod traits;
pub mod type_repr;
pub(crate) mod types;
pub mod typing;
mod unpack;
pub(crate) mod value_of_unchecked;