% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/share.R
\name{shard_share_hook}
\alias{shard_share_hook}
\alias{shard_share_hook.default}
\title{Deep Sharing Hook for Custom Classes}
\usage{
shard_share_hook(x, ctx)

\method{shard_share_hook}{default}(x, ctx)
}
\arguments{
\item{x}{The object being traversed during deep sharing.}

\item{ctx}{A context list containing:
\describe{
\item{path}{Current node path string (e.g., \code{"<root>$data@cache"})}
\item{class}{class(x) - the object's class vector}
\item{mode}{'strict' or 'balanced' - sharing mode}
\item{min_bytes}{Minimum size threshold for sharing}
\item{types}{Character vector of enabled types for sharing}
\item{deep}{Logical, always TRUE when hook is called}
}}
}
\value{
A list with optional fields:
\describe{
\item{skip_slots}{Character vector of S4 slot names to not traverse}
\item{skip_paths}{Character vector of paths to not traverse}
\item{force_share_paths}{Character vector of paths to force share (ignore min_bytes)}
\item{rewrite}{Function(x) -> x to transform object before traversal}
}
Return an empty list for default behavior (no customization).
}
\description{
S3 generic that allows classes to customize deep sharing behavior.
Override this for your class to control which slots/elements are traversed,
force sharing of small objects, or transform objects before traversal.
}
\examples{
\donttest{
shard_share_hook.MyModelClass <- function(x, ctx) {
    list(
        skip_slots = "cache",
        force_share_paths = paste0(ctx$path, "@coefficients")
    )
}

shard_share_hook.LazyData <- function(x, ctx) {
    list(
        rewrite = function(obj) {
            obj$data <- as.matrix(obj$data)
            obj
        }
    )
}
}
}
