Skip to content

Commit

Permalink
docs: copy in some postgres docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jayy-lmao committed Aug 30, 2024
1 parent d67ddf5 commit a9b0d57
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 7 deletions.
13 changes: 12 additions & 1 deletion sqlx-postgres/src/types/geometry/box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,18 @@ const ERROR: &str = "error decoding BOX";
///
/// Storage size: 32 bytes
/// Description: Rectangular box
/// Representation: ((x1,y1),(x2,y2))
/// Representation: `((x1,y1),(x2,y2))`
///
/// Boxes are represented by pairs of points that are opposite corners of the box. Values of type box are specified using any of the following syntaxes:
///
/// ```
/// ( ( x1 , y1 ) , ( x2 , y2 ) )
/// ( x1 , y1 ) , ( x2 , y2 )
/// x1 , y1 , x2 , y2
/// ```
/// where `(x1,y1) and (x2,y2)` are any two opposite corners of the box.
/// Boxes are output using the second syntax.
/// Any two opposite corners can be supplied on input, but the values will be reordered as needed to store the upper right and lower left corners, in that order.
///
/// See https://www.postgresql.org/docs/16/datatype-geometric.html#DATATYPE-GEOMETRIC-BOXES
#[derive(Debug, Clone, PartialEq)]
Expand Down
6 changes: 4 additions & 2 deletions sqlx-postgres/src/types/geometry/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ use std::str::FromStr;

const ERROR: &str = "error decoding LINE";

/// Postgres Geometric Line type
/// ## Postgres Geometric Line type
///
/// Storage size: 24 bytes
/// Description: Infinite line
/// Representation: {A, B, C}
/// Representation: `{A, B, C}`
///
/// Lines are represented by the linear equation Ax + By + C = 0, where A and B are not both zero. Values of type line are input and output in the following form:
///
/// See https://www.postgresql.org/docs/16/datatype-geometric.html#DATATYPE-LINE
#[derive(Debug, Clone, PartialEq)]
Expand Down
15 changes: 14 additions & 1 deletion sqlx-postgres/src/types/geometry/line_segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,20 @@ const ERROR: &str = "error decoding LSEG";
///
/// Storage size: 32 bytes
/// Description: Finite line segment
/// Representation: ((x1,y1),(x2,y2))
/// Representation: `((x1,y1),(x2,y2))`
///
///
/// Line segments are represented by pairs of points that are the endpoints of the segment. Values of type lseg are specified using any of the following syntaxes:
/// ```
/// [ ( x1 , y1 ) , ( x2 , y2 ) ]
/// ( ( x1 , y1 ) , ( x2 , y2 ) )
/// ( x1 , y1 ) , ( x2 , y2 )
/// x1 , y1 , x2 , y2
/// ```
/// where `(x1,y1) and (x2,y2)` are the end points of the line segment.
///
/// Line segments are output using the first syntax.
///
///
/// See https://www.postgresql.org/docs/16/datatype-geometric.html#DATATYPE-LSEG
#[derive(Debug, Clone, PartialEq)]
Expand Down
16 changes: 15 additions & 1 deletion sqlx-postgres/src/types/geometry/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,21 @@ const BYTE_WIDTH: usize = 8;
///
/// Storage size: 16+16n bytes
/// Description: Open path or Closed path (similar to polygon)
/// Representation: Open [(x1,y1),...], Closed ((x1,y1),...)
/// Representation: Open `[(x1,y1),...]`, Closed `((x1,y1),...)`
///
/// Paths are represented by lists of connected points. Paths can be open, where the first and last points in the list are considered not connected, or closed, where the first and last points are considered connected.
/// Values of type path are specified using any of the following syntaxes:
/// ```
/// [ ( x1 , y1 ) , ... , ( xn , yn ) ]
/// ( ( x1 , y1 ) , ... , ( xn , yn ) )
/// ( x1 , y1 ) , ... , ( xn , yn )
/// ( x1 , y1 , ... , xn , yn )
/// x1 , y1 , ... , xn , yn
/// ```
/// where the points are the end points of the line segments comprising the path. Square brackets `([])` indicate an open path, while parentheses `(())` indicate a closed path.
/// When the outermost parentheses are omitted, as in the third through fifth syntaxes, a closed path is assumed.
///
/// Paths are output using the first or second syntax, as appropriate.
///
/// See https://www.postgresql.org/docs/16/datatype-geometric.html#DATATYPE-GEOMETRIC-PATHS
#[derive(Debug, Clone, PartialEq)]
Expand Down
9 changes: 8 additions & 1 deletion sqlx-postgres/src/types/geometry/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ use std::str::FromStr;
///
/// Storage size: 16 bytes
/// Description: Point on a plane
/// Representation: (x, y)
/// Representation: `(x, y)`
///
/// Points are the fundamental two-dimensional building block for geometric types. Values of type point are specified using either of the following syntaxes:
/// ```
/// ( x , y )
/// x , y
/// ````
/// where x and y are the respective coordinates, as floating-point numbers.
///
/// See https://www.postgresql.org/docs/16/datatype-geometric.html#DATATYPE-GEOMETRIC-POINTS
#[derive(Debug, Clone, PartialEq)]
Expand Down
16 changes: 15 additions & 1 deletion sqlx-postgres/src/types/geometry/polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,21 @@ const BYTE_WIDTH: usize = 8;
///
/// Storage size: 40+16n bytes
/// Description: Polygon (similar to closed polygon)
/// Representation: ((x1,y1),...)
/// Representation: `((x1,y1),...)`
///
/// Polygons are represented by lists of points (the vertexes of the polygon). Polygons are very similar to closed paths; the essential semantic difference is that a polygon is considered to include the area within it, while a path is not.
/// An important implementation difference between polygons and paths is that the stored representation of a polygon includes its smallest bounding box. This speeds up certain search operations, although computing the bounding box adds overhead while constructing new polygons.
/// Values of type polygon are specified using any of the following syntaxes:
///
/// ```
/// ( ( x1 , y1 ) , ... , ( xn , yn ) )
/// ( x1 , y1 ) , ... , ( xn , yn )
/// ( x1 , y1 , ... , xn , yn )
/// x1 , y1 , ... , xn , yn
/// ```
///
/// where the points are the end points of the line segments comprising the boundary of the polygon.
/// Polygons are output using the first syntax.
///
/// Seeh ttps://www.postgresql.org/docs/16/datatype-geometric.html#DATATYPE-POLYGON
#[derive(Debug, Clone, PartialEq)]
Expand Down

0 comments on commit a9b0d57

Please sign in to comment.