#bolt #protocols #neo4j #graph-database #client-server #timezone

bolt-proto

Bolt protocol primitives: values, messages, and serialization / deserialization

14 releases (breaking)

0.12.0 Dec 28, 2022
0.11.0 Nov 24, 2021
0.10.0 Mar 30, 2021
0.9.1 Sep 18, 2020
0.3.0 Dec 25, 2019

#1561 in Encoding

Download history 65/week @ 2024-07-20 74/week @ 2024-07-27 80/week @ 2024-08-03 100/week @ 2024-08-10 125/week @ 2024-08-17 61/week @ 2024-08-24 35/week @ 2024-08-31 34/week @ 2024-09-07 28/week @ 2024-09-14 67/week @ 2024-09-21 32/week @ 2024-09-28 23/week @ 2024-10-05 44/week @ 2024-10-12 9/week @ 2024-10-19 3/week @ 2024-10-26 25/week @ 2024-11-02

85 downloads per month
Used in 6 crates (3 directly)

MIT license

84KB
2K SLoC

This crate contains the primitives used in the Bolt protocol. The Message and Value enums are of particular importance, and are the primary units of information sent and consumed by Bolt clients/servers.

The Message enum encapsulates all possible messages that can be sent between client and server.

pub enum Message {
    // V1-compatible message types
    Init(Init),
    Run(Run),
    DiscardAll,
    PullAll,
    AckFailure,
    Reset,
    Record(Record),
    Success(Success),
    Failure(Failure),
    Ignored,

    // V3+-compatible message types
    Hello(Hello),
    Goodbye,
    RunWithMetadata(RunWithMetadata),
    Begin(Begin),
    Commit,
    Rollback,

    // V4+-compatible message types
    Discard(Discard),
    Pull(Pull),

    // V4.3+-compatible message types
    Route(Route),

    // v4.4-compatible message types
    RouteWithMetadata(RouteWithMetadata),
}

See the documentation for more details.

The Value enum encapsulates all possible values that can be sent in each kind of Message. Structures like List and Map allow Values to be nested with arbitrary complexity.

pub enum Value {
    // V1-compatible value types
    Boolean(bool),
    Integer(i64),
    Float(f64),
    Bytes(Vec<u8>),
    List(Vec<Value>),
    Map(HashMap<String, Value>),
    Null,
    String(String),
    Node(Node),
    Relationship(Relationship),
    Path(Path),
    UnboundRelationship(UnboundRelationship),

    // V2+-compatible value types
    Date(NaiveDate),                       // A date without a time zone, i.e. LocalDate
    Time(NaiveTime, FixedOffset),          // A time with UTC offset, i.e. OffsetTime
    DateTimeOffset(DateTime<FixedOffset>), // A date-time with UTC offset, i.e. OffsetDateTime
    DateTimeZoned(DateTime<Tz>),           // A date-time with time zone ID, i.e. ZonedDateTime
    LocalTime(NaiveTime),                  // A time without time zone
    LocalDateTime(NaiveDateTime),          // A date-time without time zone
    Duration(Duration),
    Point2D(Point2D),
    Point3D(Point3D),
}

You should rarely ever have to construct variants directly (with the exception of Value::Null). Instead, you should typically use Value::from on the type you wish to convert. See the documentation for more details.

Dependencies

~3.5–5MB
~85K SLoC