necoherence/file_effect
Types
pub type ContentDigest {
ContentDigest(value: String)
}
Constructors
-
ContentDigest(value: String)
pub type DigestLookup {
DigestFound(ContentDigest)
DigestUnobserved(UnobservedContents)
}
Constructors
-
DigestFound(ContentDigest) -
DigestUnobserved(UnobservedContents)
pub type Digests {
Digests(entries: List(#(core.ResourceId, ContentDigest)))
}
Constructors
-
Digests(entries: List(#(core.ResourceId, ContentDigest)))
The external world normalize_path, track, read, and replace observe and update. Read and write failures stand for a boundary failure such as a permission or I/O error without modeling any particular exception type.
pub type ExternalFileState {
ExternalFileState(
files: List(#(NormalizedPath, FileRecord)),
read_failures: List(NormalizedPath),
write_failures: List(NormalizedPath),
)
}
Constructors
-
ExternalFileState( files: List(#(NormalizedPath, FileRecord)), read_failures: List(NormalizedPath), write_failures: List(NormalizedPath), )
pub type ExternalMutation {
ExternalMutation(
expected: ContentDigest,
actual: ContentDigest,
)
}
Constructors
-
ExternalMutation(expected: ContentDigest, actual: ContentDigest)
pub type FileRecord {
FileRecord(digest: ContentDigest, bytes: List(Int))
}
Constructors
-
FileRecord(digest: ContentDigest, bytes: List(Int))
pub type FileSnapshot {
FileSnapshot(
path: NormalizedPath,
contents: List(Int),
digest: ContentDigest,
)
}
Constructors
-
FileSnapshot( path: NormalizedPath, contents: List(Int), digest: ContentDigest, )
pub type NormalizedPath {
NormalizedPath(root: Bool, segments: List(String))
}
Constructors
-
NormalizedPath(root: Bool, segments: List(String))
pub type Read {
Read(
observation: core.Observation(FileSnapshot),
world: core.World,
digests: Digests,
)
}
Constructors
-
Read( observation: core.Observation(FileSnapshot), world: core.World, digests: Digests, )
pub type ReadFailure {
ReadFailure(path: NormalizedPath)
}
Constructors
-
ReadFailure(path: NormalizedPath)
pub type ReadReq {
ReadReq(
path: NormalizedPath,
world: core.World,
digests: Digests,
state: ExternalFileState,
observed_at: Int,
)
}
Constructors
-
ReadReq( path: NormalizedPath, world: core.World, digests: Digests, state: ExternalFileState, observed_at: Int, )
pub type ReplaceConflict {
ConflictStaleBasis(core.StaleBasis)
ConflictExternalMutation(ExternalMutation)
}
Constructors
-
ConflictStaleBasis(core.StaleBasis) -
ConflictExternalMutation(ExternalMutation)
pub type ReplaceContents {
ReplaceContents(
new_contents: List(Int),
new_digest: ContentDigest,
)
}
Constructors
-
ReplaceContents( new_contents: List(Int), new_digest: ContentDigest, )
pub type ReplaceRejection {
RejectMismatch(ResourcePathMismatch)
RejectUnknownResource(core.UnknownResource)
RejectUnobservedContents(UnobservedContents)
}
Constructors
-
RejectMismatch(ResourcePathMismatch) -
RejectUnknownResource(core.UnknownResource) -
RejectUnobservedContents(UnobservedContents)
pub type ReplaceReq {
ReplaceReq(
command: core.Command(ReplaceContents),
path: NormalizedPath,
world: core.World,
digests: Digests,
state: ExternalFileState,
observed_at: Int,
)
}
Constructors
-
ReplaceReq( command: core.Command(ReplaceContents), path: NormalizedPath, world: core.World, digests: Digests, state: ExternalFileState, observed_at: Int, )
pub type Replaced {
Replaced(
observation: core.Observation(FileSnapshot),
world: core.World,
digests: Digests,
state: ExternalFileState,
)
}
Constructors
-
Replaced( observation: core.Observation(FileSnapshot), world: core.World, digests: Digests, state: ExternalFileState, )
pub type ResourcePathMismatch {
ResourcePathMismatch(
resource: core.ResourceId,
path: NormalizedPath,
)
}
Constructors
-
ResourcePathMismatch( resource: core.ResourceId, path: NormalizedPath, )
pub type TrackReq {
TrackReq(
path: NormalizedPath,
world: core.World,
observed_at: Int,
)
}
Constructors
-
TrackReq( path: NormalizedPath, world: core.World, observed_at: Int, )
pub type Tracked {
Tracked(
observation: core.Observation(core.Revision),
world: core.World,
)
}
Constructors
-
Tracked( observation: core.Observation(core.Revision), world: core.World, )
pub type UnobservedContents {
UnobservedContents(resource: core.ResourceId)
}
Constructors
-
UnobservedContents(resource: core.ResourceId)
pub type WriteFailure {
WriteFailure(path: NormalizedPath)
}
Constructors
-
WriteFailure(path: NormalizedPath)
Values
pub fn lookup_digest(
digests: Digests,
resource: core.ResourceId,
) -> DigestLookup
pub fn normalize_path(
root: Bool,
raw: List(String),
) -> NormalizedPath
Reduce a raw root flag and segment list into a normalized path.
pub fn read(
req: ReadReq,
) -> core.Outcome(
Read,
core.UnknownResource,
boundary_c,
ReadFailure,
)
Read the path from the external state. A declared read failure yields a boundary failure, checked first. Otherwise an absent path is rejected as an unknown resource; a present path yields an observation of its snapshot, and its digest is recorded.
pub fn replace(
req: ReplaceReq,
) -> core.Outcome(
Replaced,
ReplaceRejection,
ReplaceConflict,
WriteFailure,
)
Apply the command as a compare-and-replace atomic write. The command’s resource must name the same file as the path; a mismatch is rejected before any digest, world, or file observation is made. A resource with no recorded digest is rejected before the world or file is touched. A revision mismatch is a stale-basis conflict; a digest mismatch after that is an external-mutation conflict. Only once every layer passes is the external state updated as a single total step.
pub fn set_digest(
digests: Digests,
resource: core.ResourceId,
digest: ContentDigest,
) -> Digests
pub fn track(
req: TrackReq,
) -> core.Outcome(Tracked, boundary_r, boundary_c, boundary_b)
Register the path as an owned resource and return its observation. An already-tracked path yields an observation of its current revision without changing the world.