pub struct UUIDExtractor;Expand description
Extracts entity UUIDs from mutation response objects.
Handles various response formats:
- Simple:
{ "id": "uuid", "name": "..." } - Nested:
{ "user": { "id": "uuid", "name": "..." } } - Array:
[{ "id": "uuid1" }, { "id": "uuid2" }]
Implementations§
Source§impl UUIDExtractor
impl UUIDExtractor
Sourcepub fn extract_entity_uuid(
response: &Value,
_entity_type: &str,
) -> Result<Option<String>>
pub fn extract_entity_uuid( response: &Value, _entity_type: &str, ) -> Result<Option<String>>
Extract a single entity UUID from mutation response.
§Arguments
response- JSON response from mutationentity_type- The entity type (e.g., “User”, “Post”)
§Returns
Ok(Some(uuid))- UUID found and validOk(None)- No UUID found (e.g., null response)
§Errors
Returns FraiseQLError::Validation if an "id" field is found but
its value is not a valid UUID v4 string.
§Examples
use fraiseql_core::cache::UUIDExtractor;
use serde_json::json;
let response = json!({"id": "550e8400-e29b-41d4-a716-446655440000"});
let uuid = UUIDExtractor::extract_entity_uuid(&response, "User").unwrap();
assert_eq!(uuid, Some("550e8400-e29b-41d4-a716-446655440000".to_string()));Sourcepub fn extract_batch_uuids(
response: &Value,
_entity_type: &str,
) -> Result<Vec<String>>
pub fn extract_batch_uuids( response: &Value, _entity_type: &str, ) -> Result<Vec<String>>
Extract multiple entity UUIDs from mutation response (batch operations).
§Arguments
response- JSON response (array or object)entity_type- The entity type (e.g., “User”, “Post”)
§Returns
List of extracted UUIDs (empty if none found)
§Errors
Returns FraiseQLError::Validation if any "id" field found in the
response is not a valid UUID v4 string.
§Examples
use fraiseql_core::cache::UUIDExtractor;
use serde_json::json;
let response = json!([
{"id": "550e8400-e29b-41d4-a716-446655440001"},
{"id": "550e8400-e29b-41d4-a716-446655440002"},
{"id": "550e8400-e29b-41d4-a716-446655440003"}
]);
let uuids = UUIDExtractor::extract_batch_uuids(&response, "User").unwrap();
assert_eq!(uuids.len(), 3);Sourcepub fn is_valid_uuid(id: &str) -> bool
pub fn is_valid_uuid(id: &str) -> bool
Validate if a string is a valid UUID format.
§Arguments
id- String to validate
§Returns
true if valid UUID format, false otherwise
§Examples
use fraiseql_core::cache::UUIDExtractor;
assert!(UUIDExtractor::is_valid_uuid("550e8400-e29b-41d4-a716-446655440000"));
assert!(!UUIDExtractor::is_valid_uuid("not-a-uuid"));Trait Implementations§
Source§impl Clone for UUIDExtractor
impl Clone for UUIDExtractor
Source§fn clone(&self) -> UUIDExtractor
fn clone(&self) -> UUIDExtractor
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for UUIDExtractor
impl RefUnwindSafe for UUIDExtractor
impl Send for UUIDExtractor
impl Sync for UUIDExtractor
impl Unpin for UUIDExtractor
impl UnsafeUnpin for UUIDExtractor
impl UnwindSafe for UUIDExtractor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more