示例#1
0
        public static byte[] AsArray(this FFIScript ffi)
        {
            var arr  = new byte[(int)ffi.len];
            var span = ffi.AsSpan();

            span.CopyTo(arr);
            return(arr);
        }
示例#2
0
        /// <summary>
        /// Be super careful that this function only works in the delegate.
        /// Because rust side will free the memory when finished calling it.
        /// If you want to use the data from out side of the delegate, use `ToArray()`
        /// instead, which will make a copy of the data.
        /// </summary>
        /// <param name="ffi"></param>
        /// <returns></returns>
        public static Span <byte> AsSpan(this FFIScript ffi)
        {
            var size = (int)ffi.len;

            unsafe
            {
                return(new Span <byte>(ffi.ptr.ToPointer(), size));
            }
        }