toSodiumPointer<T extends NativeType> method
SodiumPointer<T>
toSodiumPointer<T extends NativeType>(
- LibSodiumFFI sodium, {
- MemoryProtection memoryProtection = MemoryProtection.readWrite,
Converts the list to a sodium pointer
This is done by first allocating a SodiumPointer with length elements and the copying all data from the list to the pointer.
If you want the memoryProtection
to changed right after the copying is
done, you can do so via this parameter. By default, the pointer keeps the
default MemoryProtection.readWrite mode.
Implementation
SodiumPointer<T> toSodiumPointer<T extends NativeType>(
LibSodiumFFI sodium, {
MemoryProtection memoryProtection = MemoryProtection.readWrite,
}) {
if (this is! TypedData) {
throw UnsupportedError(
'The toSodiumPointer extension can only be used on typed data lists '
'like Uint8List',
);
}
final typedDataThis = this as TypedData;
if (_StaticallyTypedSizeOf.staticSizeOf<T>() <
typedDataThis.elementSizeInBytes) {
throw ArgumentError.value(
T,
'T',
'A $runtimeType does not fit into SodiumPointer of type',
);
}
return SodiumPointer.fromList(
sodium,
this,
memoryProtection: memoryProtection,
);
}