-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: simplify
proof-of-sql-parser
(#59)
- Loading branch information
Showing
26 changed files
with
120 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use thiserror::Error; | ||
|
||
/// Errors related to time operations, including timezone and timestamp conversions.s | ||
#[derive(Error, Debug, Eq, PartialEq, Serialize, Deserialize)] | ||
pub enum PoSQLTimestampError { | ||
/// Error when the timezone string provided cannot be parsed into a valid timezone. | ||
#[error("invalid timezone string: {0}")] | ||
InvalidTimezone(String), | ||
|
||
/// Error indicating an invalid timezone offset was provided. | ||
#[error("invalid timezone offset")] | ||
InvalidTimezoneOffset, | ||
|
||
/// Indicates a failure to convert between different representations of time units. | ||
#[error("Invalid time unit")] | ||
InvalidTimeUnit(String), | ||
|
||
/// The local time does not exist because there is a gap in the local time. | ||
/// This variant may also be returned if there was an error while resolving the local time, | ||
/// caused by for example missing time zone data files, an error in an OS API, or overflow. | ||
#[error("Local time does not exist because there is a gap in the local time")] | ||
LocalTimeDoesNotExist, | ||
|
||
/// The local time is ambiguous because there is a fold in the local time. | ||
/// This variant contains the two possible results, in the order (earliest, latest). | ||
#[error("Unix timestamp is ambiguous because there is a fold in the local time.")] | ||
Ambiguous(String), | ||
|
||
/// Represents a catch-all for parsing errors not specifically covered by other variants. | ||
#[error("Timestamp parsing error: {0}")] | ||
ParsingError(String), | ||
|
||
/// Represents a failure to parse a provided time unit precision value, PoSQL supports | ||
/// Seconds, Milliseconds, Microseconds, and Nanoseconds | ||
#[error("Timestamp parsing error: {0}")] | ||
UnsupportedPrecision(String), | ||
} | ||
|
||
// This exists because TryFrom<DataType> for ColumnType error is String | ||
impl From<PoSQLTimestampError> for String { | ||
fn from(error: PoSQLTimestampError) -> Self { | ||
error.to_string() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
mod error; | ||
/// Errors related to time operations, including timezone and timestamp conversions. | ||
pub use error::PoSQLTimestampError; | ||
mod timestamp; | ||
/// Defines an RFC3339-formatted timestamp | ||
pub mod timestamp; | ||
pub use timestamp::PoSQLTimestamp; | ||
mod timezone; | ||
/// Defines a timezone as count of seconds offset from UTC | ||
pub mod timezone; | ||
pub use timezone::PoSQLTimeZone; | ||
mod unit; | ||
/// Defines the precision of the timestamp | ||
pub mod unit; | ||
pub use unit::PoSQLTimeUnit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.