date and file functions - #269
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds new standard-library runtime function sets for date handling and file payload inspection, addressing Issue #265 (“Implement new Functions: Date & Files”) by expanding the taurus-core runtime function catalog.
Changes:
- Registers new
std::date::*functions for creating, parsing, and formatting DATE values (microseconds since Unix epoch, UTC). - Adds
std::file::sizefor computing decoded byte size of base64-encoded FILE payloads. - Introduces
chronoas a workspace dependency used by the new date handlers.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/taurus-core/src/runtime/functions/mod.rs | Wires the new date and file function sets into the runtime registry. |
| crates/taurus-core/src/runtime/functions/date.rs | Implements std::date::* handlers (now/from/from_text/from_unix/format) with unit tests. |
| crates/taurus-core/src/runtime/functions/file.rs | Implements std::file::size with unit tests. |
| crates/taurus-core/Cargo.toml | Adds chrono dependency for taurus-core. |
| Cargo.toml | Adds workspace chrono dependency configuration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+13
to
+37
| use base64::Engine; | ||
| use tucana::shared::{Struct, value::Kind}; | ||
|
|
||
| pub(crate) const FUNCTIONS: &[FunctionRegistration] = | ||
| &[FunctionRegistration::eager("std::file::size", size, 1)]; | ||
|
|
||
| fn size( | ||
| args: &[Argument], | ||
| _ctx: &mut ValueStore, | ||
| _run: &mut crate::handler::registry::ThunkRunner<'_>, | ||
| ) -> Signal { | ||
| args!(args => file: Struct); | ||
|
|
||
| // `throwsError: false` — a missing/malformed `value` field reports size 0 | ||
| // rather than failing. | ||
| let byte_len = match file.fields.get("value").and_then(|v| v.kind.as_ref()) { | ||
| Some(Kind::StringValue(base64_value)) => base64::prelude::BASE64_STANDARD | ||
| .decode(base64_value) | ||
| .map(|bytes| bytes.len()) | ||
| .unwrap_or(0), | ||
| _ => 0, | ||
| }; | ||
|
|
||
| Signal::Success(value_from_i64(byte_len as i64)) | ||
| } |
Comment on lines
+80
to
+87
| let (Ok(day), Ok(hour), Ok(minute), Ok(second)) = ( | ||
| u32::try_from(day), | ||
| u32::try_from(hour), | ||
| u32::try_from(minute), | ||
| u32::try_from(second), | ||
| ) else { | ||
| return fail("day, hour, minute and second must be non-negative"); | ||
| }; |
GitLab Pipeline ActionGeneral informationLink to pipeline: https://gitlab.com/code0-tech/development/taurus/-/pipelines/2724026451 Status: Passed Job summariesdocs:previewDocumentation preview available at https://code0-tech.gitlab.io/-/development/telescopium/-/jobs/15659433759/artifacts/out/index.html |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves: #265