---
title: "loadResource(resource:options:replyHandler:)"
framework: fskit
role: symbol
role_heading: Instance Method
path: "fskit/fsunaryfilesystemoperations/loadresource(resource:options:replyhandler:)"
---

# loadResource(resource:options:replyHandler:)

Requests that the file system load a resource and present it as a volume.

## Declaration

```swift
func loadResource(resource: FSResource, options: FSTaskOptions, replyHandler reply: @escaping @Sendable (FSVolume?, (any Error)?) -> Void)
```

```swift
func loadResource(resource: FSResource, options: FSTaskOptions) async throws -> FSVolume
```

## Parameters

- `resource`: An doc://FSKit/documentation/FSKit/FSResource to load.
- `options`: An doc://FSKit/documentation/FSKit/FSTaskOptions object specifying options to apply when loading the resource. An doc://FSKit/documentation/FSKit/FSUnaryFileSystem supports two options: -f for “force” and --rdonly for read-only. The file system must remember if the read-only option is present.
- `reply`: A block or closure that your implementation invokes when it finishes setting up or encounters an error. Pass a subclass of FSVolume as the first parameter if loading succeeds. If loading fails, pass an error as the second parameter.

## Discussion

Discussion Implement this method by inspecting the provided resource and verifying it uses a supported format. If the resource does use a supported format, create a subclass of FSVolume, clear the container error state, and invoke the reply callback, passing your volume as a parameter. If loading can’t proceed, invoke reply and send an appropriate error as the second parameter.

## See Also

### Loading and unloading resources

- [unloadResource(resource:options:replyHandler:)](fskit/fsunaryfilesystemoperations/unloadresource(resource:options:replyhandler:).md)
- [didFinishLoading()](fskit/fsunaryfilesystemoperations/didfinishloading().md)
