Skip to main content

Module ldp

Module ldp 

Source
Expand description

Linked Data Platform (LDP) resource and container semantics.

Phase 2 scope:

  • Full Link header set (type + acl + describedby + storage root).
  • Prefer header parsing (PreferMinimalContainer, PreferContainedIRIs).
  • Accept-Post header for containers.
  • PATCH via N3 (solid-protocol PATCH): insert, delete, where.
  • PATCH via SPARQL-Update (INSERT DATA, DELETE DATA, DELETE WHERE).
  • Content negotiation: Turtle, JSON-LD, N-Triples, RDF/XML.
  • Server-managed triples (dc:modified, stat:size, ldp:contains).
  • .meta sidecar resolution.

The module intentionally uses a tiny, in-crate RDF triple model so the crate stays free of the heavier sophia / oxigraph dep trees. Only Turtle-subset parsing required for real-world Solid Pod PATCH flows is supported; client-supplied RDF is parsed via the N-Triples fallback whenever the Turtle fast path hits something exotic.

Modules§

iri
Well-known IRI constants used in LDP, WAC, and server-managed triples.

Structs§

ByteRange
A parsed byte range. end is inclusive per RFC 7233 §2.1.
ContainerMember
Graph
Minimal RDF graph — a sorted set of triples.
OptionsResponse
Build the set of values returned on OPTIONS for a Solid resource.
PatchOutcome
Outcome of evaluating a PATCH request.
PreferHeader
Parsed Prefer header value. Non-return=representation preferences are ignored (the LDP spec allows this).
Triple

Enums§

ConditionalOutcome
Outcome of evaluating conditional request headers against a current resource ETag.
ContainerRepresentation
What portions of a container representation the client wants.
PatchCreateOutcome
Outcome of applying a PATCH to a path that had no prior resource.
PatchDialect
Pick a PATCH dialect from the Content-Type header.
RangeOutcome
Outcome of evaluating Range: against a known resource length. Full → 200 (no Range: header); Partial → 206; NotSatisfiable → 416 (not 412, which the old parse_range_header conflated).
RdfFormat
Term

Constants§

ACCEPT_PATCH
Accept-Patch advertising the PATCH dialects supported.
ACCEPT_POST
MIME types recognised by the content negotiator. The order matters: the first format that matches the Accept header wins, and if the client provides */* the server defaults to Turtle.
CACHE_CONTROL_RDF
RFC 7234 Cache-Control directive for RDF response variants.
MAX_SLUG_BYTES
Maximum byte length of a client-supplied Slug header. JSS caps at 255 bytes (POSIX filename limit); we match for interop.
SERVER_MANAGED_PREDICATES
List of predicates clients are not allowed to set directly. These are overwritten by the server on PUT.

Traits§

LdpContainerOps

Functions§

apply_json_patch
Apply a JSON Patch document (RFC 6902) to a serde_json::Value in place. Returns Err(PodError::PreconditionFailed) when a test operation fails, Err(PodError::Unsupported) for malformed patches.
apply_n3_patch
Apply a solid-protocol N3 PATCH document to target.
apply_patch_to_absent
Apply a PATCH document to an absent resource by seeding an empty graph and running the dialect-specific patcher. JSON Patch is unsupported in this path.
apply_sparql_patch
Apply a SPARQL 1.1 Update document (INSERT DATA, DELETE DATA, DELETE WHERE) to target using spargebra for parsing.
cache_control_for
Return the Cache-Control header value appropriate for a response of the supplied content_type, or None to leave the header unset. RDF variants always get CACHE_CONTROL_RDF; non-RDF payloads (binary blobs, images, etc.) are left to caller policy.
evaluate_preconditions
Evaluate If-Match and If-None-Match precondition headers against the current ETag of a resource. The caller passes whatever is observed on the storage side; None for the ETag means the resource does not exist.
find_illegal_server_managed
Return the list of client-supplied triples that attempt to set server-managed predicates. These MUST be ignored at PUT time.
infer_dotfile_content_type
Infer a content-type for auxiliary “dotfile” resources (.acl, .meta, and their *.acl / *.meta suffix variants) whose extension-based lookup would otherwise fail.
is_acl_path
Return whether a path addresses an ACL sidecar.
is_container
Return whether a path addresses an LDP container.
is_meta_path
Return whether a path addresses a .meta sidecar.
is_rdf_content_type
Return true if content_type identifies an RDF serialisation the server emits through content negotiation or stores natively. Matches the formats advertised in ACCEPT_POST plus text/n3 and application/trig (JSS parity). Parameters (e.g. ; charset=utf-8) are tolerated.
link_headers
Build the full set of Link headers for a given resource path.
meta_sidecar_for
Compute the .meta sidecar for a resource.
negotiate_format
Pick the best RDF format based on an Accept header.
not_found_headers
Build the header set returned on 404 Not Found for an LDP path.
options_for
parse_range_header
Parse a Range: header value of the form bytes=start-end or bytes=start- or bytes=-suffix. Multi-range is intentionally not supported — Solid Pods treat non-rangeable media (JSON-LD, Turtle) as opaque and the binary path is the only consumer.
parse_range_header_v2
JSS-parity range parser. Same grammar as parse_range_header but maps “empty body + header present” and “range past end” to NotSatisfiable. Malformed headers still return Err so callers can reply 400.
patch_dialect_from_mime
render_container
Backwards-compatible alias for the Phase 1 API.
render_container_jsonld
Render a container as JSON-LD respecting a Prefer header.
render_container_turtle
Render a container as Turtle.
resolve_slug
Resolve the target path when POSTing to a container.
server_managed_triples
Compute the server-managed triples for a resource (dc:modified, stat:size, and for containers ldp:contains entries).
slice_range
Slice a body buffer to a byte range. The slice is a zero-copy view; callers are expected to copy_from_slice or similar when returning it through an HTTP framework.
vary_header
Value of the Vary: header depending on whether content negotiation is enabled. Authorization and Origin are always listed so shared caches never collapse an authenticated and an anonymous response onto the same cache entry.