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)Err(_)- Invalid UUID format
§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)
§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